Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "Marshaling" in [All]

kernel32

.

The unmanaged prototype contains a return directive because the CreateSymbolicLink API function returns BOOLEAN, a one-byte data type. The default marshaling for bool is four bytes (to allow seamless integration with BOOL return values). If you were to use the default marshaling for BOOLEAN values, it's likely that you will get erroneous results. The return directive forces PInvoke to marshal just one byte of the return value. Source: http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=762&ns=16196

.

The original GetCommandLine function returns a pointer to a buffer allocated and owned by the operating system. When marshaling strings as return types, the interop marshaler assumes it must free the memory that the original LPTSTR type pointed to by the function. To prevent the marshaler from automatically reclaiming this memory, the managed GetCommandLine prototype returns an IntPtr type instead of a string. The Marshal.PtrToStringAuto method copies the unmanaged LPSTR type to a managed string object, widening the character format, if required.

.

Q. For the above VB DllImport declaration, Visual Studio's Code Analysis throws error 'CA2101: Specify marshaling for P/Invoke string arguments'.

ole32

.
Summary
Creates an aggregatable object capable of context-dependent marshaling.

Structures

.

See this MSDN reference: Default Marshaling for Strings

.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondefaultmarshalingforstrings.asp

.

Don't declare a value for the Pack size. If you omit it, the correct value is used when marshaling and a single SHFILEOPSTRUCT can be used for both 32-bit and 64-bit operation.

.

The constructor of this structure "unmarshal" WLAN_INTERFACE_INFO_LIST data obtained by calling WlanEnumInterfaces(). This is a good example on how to marshal pointer-to-pointer case in C++ world ( kind of confusing because in C# or Managed Environment more broadly, it is just reference, so as you can see from the implementation for C#, it is to be treated like just a single pointer case. Also, this example shows how to handle an array for the InterfaceInfo inside of this structure. It needs two level of marshaling and this example shows that.

.

The constructor of this structure "unmarshal" WLAN_INTERFACE_INFO_LIST data obtained by calling WlanEnumInterfaces(). This is a good example on how to marshal pointer-to-pointer case in C++ world ( kind of confusing because in C# or Managed Environment more broadly, it is just reference, so as you can see from the implementation for C#, it is to be treated like just a single pointer case. Also, this example shows how to handle an array for the InterfaceInfo inside of this structure. It needs two level of marshaling and this example shows that.

user32

.

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpcondefaultmarshalingforstrings.htm

.

This is apparently not accurate as the P/Invoke layer automatically generates a marshaling stub at a fixed address:

glossary

.

     In addition all use of function dlls requires marshaling

advapi32

.

The stuff on this page about needing custom marshaling are just wrong.

.

Needs extensive custom marshaling code. See CredRead to for an example on the custom marshaling code.

httpapi

.

If your use of this API is focused around a single value of ConfigId, you may want to change the IntPtr (pConfigInformation) to point directly to a managed version of the correct underlying structure and let the default marshaller take care of the interop layer marshaling for you (and your memory management).

.

If your use of this API is focused around a single value of ConfigId, you may want to change the IntPtr (pConfigInformation) to point directly to a managed version of the correct underlying structure and let the default marshaller take care of the interop layer marshaling for you (and your memory management).

.

If your use of this API is focused around a single value of ConfigId, you may want to change the IntPtr (pConfigInformation) to point directly to a managed version of the correct underlying structure and let the default marshaller take care of the interop layer marshaling for you (and your memory management).

netapi32

.

The largest challenge is marshaling the pointer to the array of structures which the output is placed in.

.

In this example, I use a do/while which doubles the size of the buffer until it is large enough to contain all of the groups that are on the server. The API call is designed so that you can read sequentially (ERROR_MORE_DATA), but I didn't want to deal with marshaling returned data stored in more than one of the pointers to the array of structures which the output is placed in!

.

The largest challenge is marshaling the pointer to the array of structures which the output is placed in.

.

In this example, I use a do/while which doubles the size of the buffer until it is large enough to contain all of the groups that are on the server. The API call is designed so that you can read sequentially (ERROR_MORE_DATA), but I didn't want to deal with marshaling returned data stored in more than one of the pointers to the array of structures which the output is placed in!


 
Access PInvoke.net directly from VS: