'HWND *hWnd' parameter in vc++ 6. 'ByRef hwnd As Any' parameter should now be ????

int EXPORTED foo (long iX, long iY, HWND *hWnd) is the vc++ 6.0 function.

Public Declare Function foo Lib "foo.dll" (ByVal iX As Integer, ByVal iY As Integer, ByRef hwnd As Any) As Integer

is the vb6 function declaration.

What should be my VB.NET 2.0 function declaration for that same vc++ 6 method

Thank you,

-greg



Answer this question

'HWND *hWnd' parameter in vc++ 6. 'ByRef hwnd As Any' parameter should now be ????

  • RavindraPatil

    I notice the <Out()> What is the purpose of that

    IntPtr sounds right Abel. That is what I have been seeing as the solution. Thank you. -greg

    A platform-specific type that is used to represent a pointer or a handle.

    The IntPtr type is designed to be an integer whose size is platform-specific. That is, an instance of this type is expected to be 32-bits on 32-bit hardware and operating systems, and 64-bits on 64-bit hardware and operating systems.

    The IntPtr type can be used by languages that support pointers, and as a common means of referring to data between languages that do and do not support pointers.

    IntPtr objects can also be used to hold handles. For example, instances of IntPtr are used extensively in the System.IO.FileStream class to hold file handles.


  • WolfgangEngel

    For WIN32 handles most of the time you need to to use the IntPtr data type:

    Public Declare Function foo Lib "foo.dll" (ByVal iX As Integer, ByVal iY As Integer, <Out()>ByRef hwnd As IntPtr) As Integer

    Hope this helps,



  • RubenPieters

    The purpose of <Out()> is to indicate the interop marshaler, that the parameter is "out" only. With this information the marshaler, will only copy the information on the way out, it is mainly useful to improve performance when marshaling large amounts of data.

  • 'HWND *hWnd' parameter in vc++ 6. 'ByRef hwnd As Any' parameter should now be ????