c# Programming Glossary: marshal.ptrtostructure
How do I access ARP-protocol information through .NET? http://stackoverflow.com/questions/1148778/how-do-i-access-arp-protocol-information-through-net the structure information. table index MIB_IPNETROW Marshal.PtrToStructure new IntPtr currentBuffer.ToInt64 index Marshal.SizeOf typeof..
How do you retrieve a list of logged-in/connected users in .NET? http://stackoverflow.com/questions/132620/how-do-you-retrieve-a-list-of-logged-in-connected-users-in-net i 0 i sessionCount i WTS_SESSION_INFO si WTS_SESSION_INFO Marshal.PtrToStructure System.IntPtr currentSession typeof WTS_SESSION_INFO currentSession..
A C# equivalent of C's fread file i/o http://stackoverflow.com/questions/1935851/a-c-sharp-equivalent-of-cs-fread-file-i-o pByteData hByteData.AddrOfPinnedObject this foobarStruct Marshal.PtrToStructure pByteData this.GetType hByteData.Free The reason I have two.. GCHandle.Alloc mBuffer GCHandleType.Pinned try retval T Marshal.PtrToStructure hdl.AddrOfPinnedObject typeof T finally hdl.Free return retval..
How to get the logon SID in c# http://stackoverflow.com/questions/2146153/how-to-get-the-logon-sid-in-c-sharp retVal string.Empty TOKEN_GROUPS groups TOKEN_GROUPS Marshal.PtrToStructure TokenInformation typeof TOKEN_GROUPS int sidAndAttrSize Marshal.SizeOf.. i SID_AND_ATTRIBUTES sidAndAttributes SID_AND_ATTRIBUTES Marshal.PtrToStructure new IntPtr TokenInformation.ToInt64 i sidAndAttrSize IntPtr.Size..
Reading a C/C++ data structure in C# from a byte array http://stackoverflow.com/questions/2871/reading-a-c-c-data-structure-in-c-sharp-from-a-byte-array GCHandle.Alloc buff GCHandleType.Pinned MyStuff NewStuff Marshal.PtrToStructure handle.AddrOfPinnedObject typeof NewStuff handle.Free Is there.. bytes GCHandleType.Pinned NewStuff stuff NewStuff Marshal.PtrToStructure handle.AddrOfPinnedObject typeof NewStuff handle.Free return.. handle GCHandle.Alloc bytes GCHandleType.Pinned T stuff T Marshal.PtrToStructure handle.AddrOfPinnedObject typeof T handle.Free return stuff..
Changing master volume level http://stackoverflow.com/questions/294292/changing-master-volume-level int i 0 i mlc.cControls i MIXERCONTROL mxc MIXERCONTROL Marshal.PtrToStructure IntPtr int mlc.pamxctrl int mlc.cbmxctrl i typeof MIXERCONTROL.. MIXER.OBJECTF_MIXER VOLUME rtn VOLUME Marshal.PtrToStructure mcd.paDetails typeof VOLUME Marshal.FreeHGlobal mcd.paDetails..
How to convert a structure to a byte array in C#? http://stackoverflow.com/questions/3278827/how-to-convert-a-structure-to-a-byte-array-in-c size Marshal.Copy arr 0 ptr size str CIFSPacket Marshal.PtrToStructure ptr str.GetType Marshal.FreeHGlobal ptr return str In your structure..
Using Process.Start() to start a process as a different user from within a Windows Service http://stackoverflow.com/questions/362419/using-process-start-to-start-a-process-as-a-different-user-from-within-a-windo ptr SECURITY_DESCRIPTOR_REVISION sd SECURITY_DESCRIPTOR Marshal.PtrToStructure ptr typeof SECURITY_DESCRIPTOR result SetSecurityDescriptorDacl..
How to get IntPtr from byte[] in C# http://stackoverflow.com/questions/537573/how-to-get-intptr-from-byte-in-c-sharp you could declare a struct with one property and then use Marshal.PtrToStructure but that would still require allocating unmanaged memory. Edit..
Using C#, how does one figure out what process locked a file? http://stackoverflow.com/questions/860656/using-c-how-does-one-figure-out-what-process-locked-a-file ref nLength objBasic Win32API.OBJECT_BASIC_INFORMATION Marshal.PtrToStructure ipBasic objBasic.GetType Marshal.FreeHGlobal ipBasic IntPtr.. nLength objObjectType Win32API.OBJECT_TYPE_INFORMATION Marshal.PtrToStructure ipObjectType objObjectType.GetType if Is64Bits ipTemp new.. nLength objObjectName Win32API.OBJECT_NAME_INFORMATION Marshal.PtrToStructure ipObjectName objObjectName.GetType if Is64Bits ipTemp new..
Instantiate an object with a runtime-determined type http://stackoverflow.com/questions/981330/instantiate-an-object-with-a-runtime-determined-type getTypeFromEnum val structType myStruct structType Marshal.PtrToStructure IntPtr structType This is obviously not valid code but I hope..
|