Desktop Functions: Smart Device Functions:
|
Search Results for "SIZE" in [All]wintrust
UInt32 StructSize = (UInt32)Marshal.SizeOf(typeof(WinTrustFileInfo));
UInt32 StructSize = (UInt32)Marshal.SizeOf(typeof(WinTrustData));
FileInfoPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(WinTrustFileInfo))); [Michael Zarlenga] First, thank you so much for this code! You saved me a lot of work and time. I also experienced corrupted memory issues (access violation exceptions). The problem is, as soon as you exit the WinTrustData constructor, WinTrustFileInfo can be destroyed, before (or even during) the call into WinVerifyTrust. To explicitly call .Dispose() on WinTrustFileInfo from WinTrustData, you need the object reference held in a scope external to the constructor but then sizeof WinTrustData will be wrong. Long story short, I solved that by instantiating a WinTrustFileInfo object myself and passing that to the WinTrustData constructor to use. I implemented .Dispose() on WinTrustData and WinTrustFileInfo and called them both, myself, after the call to WinVerifyTrust completed: cfgmgr32
static extern uint CM_Get_Device_Interface_List_Size(out uint size, ref Guid interfaceClassGuid, string deviceID, uint flags);
static extern uint CM_Get_Device_Interface_List_Size(out uint size, ref Guid interfaceClassGuid, string deviceID, uint flags);
InvalidStructureSize = 0x0000003B Delegates
long TotalFileSize,
long StreamSize,
/// <param name="dwName">The size of the power scheme name string, in bytes.</param>
/// <param name="dwDesc">The size of the description string, in bytes.</param>
''' <param name="dwName">The size of the power scheme name string, in bytes.</param>
''' <param name="dwDesc">The size of the description string, in bytes.</param> ole32
/// be allocated with a size of zero. If hGlobal is NULL, CreateILockBytesOnHGlobal
/// internally allocates a new shared memory block of size zero.</param>
int SizeOfIstream = ByteSizeOfIPStreamInit(pPersistStream) * 2; // two bytes per value -- See my OleSaveToStream (ole32)
IntPtr nativePtr = Marshal.AllocHGlobal(SizeOfIstream); //buffer.Length); // allocate space on the native heap
Marshal.Copy(buffer, 0, nativePtr, SizeOfIstream); // copy byte array to native heap 10: OleCreate
int cObjects, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.IUnknown)] object[] lplpUnk,
int cPages, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] Guid[] lpPageClsID,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.IUnknown)] object[] lplpUnk,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] Guid[] lpPageClsID,
UInt32 cObjects, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4, ArraySubType = UnmanagedType.IUnknown)] object[] lplpUnk,
UInt32 cPages, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] Guid[] lpPageClsID, 12: OleLoad
pStm.Read(data, sizeof(ushort), IntPtr.Zero);
pStm.Read(data, sizeof(ushort), IntPtr.Zero); 14: OleSave
public int ByteSizeOfIPStreamInit(IPersistStreamInit pPersistStream)
iSzOfStreamInBytes = IStreamSizeRead(IPtrStream);
public int IStreamSizeRead(IStream pOutStm)
pOutStm.Seek(0, 0, IntPtr.Zero);// Get size of the stream and read its contents to a byte array.
byte[] data = new byte[fileinfo.cbSize];
int sizeOfInt32 = Marshal.SizeOf(typeof(int));
IntPtr pRead = Marshal.AllocHGlobal(sizeOfInt32); 15: OleSaveToStream
public int ByteSizeOfIPStreamInit(IPersistStreamInit pPersistStream)
iSzOfStreamInBytes = IStreamSizeRead(IPtrStream);
public int IStreamSizeRead(IStream pOutStm)
pOutStm.Seek(0, 0, IntPtr.Zero);// Get size of the stream and read its contents to a byte array.
byte[] data = new byte[fileinfo.cbSize];
int sizeOfInt32 = Marshal.SizeOf(typeof(int));
IntPtr pRead = Marshal.AllocHGlobal(sizeOfInt32); Guids generated with this will return the name using the FmtIdToPropStgName Function, and can be used to generate a new IPropertyStorage interface with IPropertySetStorage.Create(). The name returned will be filled to 26 chars with the letter 'a' due to the fixed size of a Guid and the fact that we're passing all zeros in the BitArray after the name finishes to reach this size. 17: STGC Define the ulSectorSize member of the STGOPTIONS structure using type uint (which is 32-bits in C#) instead of ulong (which is 64-bits in C#). credui
''' <param name="pcbPackedCredentials">The the size of the buffer.</param> To determine required buffer size, call first with pPackedCredentials = IntPtr.Zero. Should return error code 160, but pcbPackedCredentials will be populated with the expected buffer size. Use Marshal.AllocCoTaskMem() to allocate the appropriate buffer, then call again, this time passing the allocated buffer.
int inCredSize = 1024;
IntPtr inCredBuffer = Marshal.AllocCoTaskMem(inCredSize);
CredPackAuthenticationBuffer(0, username, password, inCredBuffer, ref inCredSize);
creditUI.cbSize = Marshal.SizeOf(creditUI);
creditUI.cbSize = Marshal.SizeOf(creditUI);
uint InAuthBufferSize,
out uint refOutAuthBufferSize,
''' <param name="ulInAuthBufferSize">Size of the input authentication buffer.</param>
''' <param name="pulOutAuthBufferSize">Size of the output authentication buffer.</param>
ByVal ulInAuthBufferSize As UInt32, _
ByRef pulOutAuthBufferSize As UInt32, _
public int cbSize;
uint outCredSize;
credui.cbSize = Marshal.SizeOf(credui);
0, //...and the size goes here. You also have to add CREDUIWIN_IN_CRED_ONLY to the flags (last argument).
out outCredSize,
/*Unpack your credentials (outCredBuffer, outCredSize) with 'CredUnPackAuthenticationBuffer()'
public int cbSize;
private static extern int CredUIPromptForWindowsCredentials(ref CREDUI_INFO notUsedHere, int authError, ref uint authPackage, IntPtr InAuthBuffer, uint InAuthBufferSize, out IntPtr refOutAuthBuffer, out uint refOutAuthBufferSize, ref bool fSave, int flags);
credui.cbSize = Marshal.SizeOf(credui);
uint outCredSize;
int result = CredUIPromptForWindowsCredentials(ref credui, 0,ref authPackage,IntPtr.Zero, 0, out outCredBuffer, out outCredSize, ref save, 1 /* Generic */);
if (CredUnPackAuthenticationBuffer(0, outCredBuffer, outCredSize, usernameBuf, ref maxUserName, domainBuf, ref maxDomain, passwordBuf, ref maxPassword)) opengl32
GL_POINT_SIZE = 0x0B11,
GL_POINT_SIZE_RANGE = 0x0B12,
GL_POINT_SIZE_GRANULARITY = 0x0B13,
GL_PIXEL_MAP_I_TO_I_SIZE = 0x0CB0,
GL_PIXEL_MAP_S_TO_S_SIZE = 0x0CB1,
GL_PIXEL_MAP_I_TO_R_SIZE = 0x0CB2,
GL_PIXEL_MAP_I_TO_G_SIZE = 0x0CB3,
GL_PIXEL_MAP_I_TO_B_SIZE = 0x0CB4,
GL_PIXEL_MAP_I_TO_A_SIZE = 0x0CB5,
GL_PIXEL_MAP_R_TO_R_SIZE = 0x0CB6,
GL_PIXEL_MAP_G_TO_G_SIZE = 0x0CB7,
GL_PIXEL_MAP_B_TO_B_SIZE = 0x0CB8,
GL_PIXEL_MAP_A_TO_A_SIZE = 0x0CB9,
GL_MAX_TEXTURE_SIZE = 0x0D33,
GL_FEEDBACK_BUFFER_SIZE = 0x0DF1,
GL_SELECTION_BUFFER_SIZE = 0x0DF4,
GL_TEXTURE_RED_SIZE = 0x805C,
GL_TEXTURE_GREEN_SIZE = 0x805D,
GL_TEXTURE_BLUE_SIZE = 0x805E,
GL_TEXTURE_ALPHA_SIZE = 0x805F,
GL_TEXTURE_LUMINANCE_SIZE = 0x8060,
GL_TEXTURE_INTENSITY_SIZE = 0x8061,
GL_VERTEX_ARRAY_SIZE = 0x807A,
GL_COLOR_ARRAY_SIZE = 0x8081,
GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088,
GL_VERTEX_ARRAY_SIZE_EXT = 0x807A,
GL_COLOR_ARRAY_SIZE_EXT = 0x8081,
GL_TEXTURE_COORD_ARRAY_SIZE_EXT = 0x8088,
GL_COLOR_TABLE_RED_SIZE_EXT = 0x80DA,
GL_COLOR_TABLE_GREEN_SIZE_EXT = 0x80DB,
GL_COLOR_TABLE_BLUE_SIZE_EXT = 0x80DC,
GL_COLOR_TABLE_ALPHA_SIZE_EXT = 0x80DD,
GL_COLOR_TABLE_LUMINANCE_SIZE_EXT = 0x80DE,
GL_COLOR_TABLE_INTENSITY_SIZE_EXT = 0x80DF,
public static extern void glColorPointer(int size, uint type, int stride, int[] pointer);
public static extern void glFeedbackBuffer(int size, uint type, float[] buffer);
public static extern void glPixelMapfv(uint map, int mapsize, float[] values);
public static extern void glPixelMapuiv(uint map, int mapsize, uint[] values);
public static extern void glPixelMapusv(uint map, int mapsize, ushort[] values);
public static extern void glPointSize(float size);
public static extern void glSelectBuffer(int size, uint[] buffer);
public static extern void glTexCoordPointer(int size, uint type, int stride, float[] pointer);
public static extern void glVertexPointer(int size, uint type, int stride, float[] pointer); ntdsapi24: DsCrackNames
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPTStr, SizeParamIndex = 4)]
<MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.LPTStr, SizeParamIndex:=4)> ByVal rpNames As String(), _
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPTStr, SizeParamIndex = 4)]
int stSize = Marshal.SizeOf(strType);
curptr = new IntPtr(rItems.ToInt64() + (i * stSize));
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
// size our final array
Marshal.SizeOf(typeof(NtdsHelper.DS_DOMAIN_CONTROLLER_INFO_2))); 26: DsMapSchemaGuids
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
int typeSize = Marshal.SizeOf(typeof(DS_SCHEMA_GUID_MAP));
(long)guidPointer + i * typeSize MinCore
static extern int GetFileVersionInfoSize(string fileName, [Out]IntPtr dummy);
Declare Function GetFileVersionInfoSize Lib "Api-ms-win-core-version-l1-1-0.dll" (fileName As String, <Out> dummy As IntPtr) As Integer Use this declaration on Windows 10. On previous versions use http://pinvoke.net/default.aspx/version/GetFileVersionInfoSize.html
GetFileVersionInfoSize(@"c:\someFolder\someFile.dll", IntPtr.Zero); hhctrl28: HtmlHelp
public Size Size
return new Size(this.right - this.left, this.bottom - this.top);
internal int cbStruct = Marshal.SizeOf(typeof(HH_POPUP)); httpapi
IntPtr configInformation = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
int configInformationSize = Marshal.SizeOf(urlAclSet);
configInformationSize,
int size = Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_QUERY));
IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_QUERY)));
size = Marshal.SizeOf(inputConfigInfoQuery);
Marshal.SizeOf(inputConfigInfoQuery),
Marshal.SizeOf(inputConfigInfoQuery),
IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
Marshal.SizeOf(inputConfigInfoSet),
Marshal.SizeOf(inputConfigInfoSet),
Marshal.SizeOf(inputConfigInfoSet),
byte[] socketBytes = new byte[socketAddress.Size];
// Should copy the first 16 bytes (the SocketAddress has a 32 byte buffer, the size will only be 16,
for (int i = 0; i < socketAddress.Size; ++i)
IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_SET)));
Marshal.SizeOf(configSslSet),
Marshal.SizeOf(configSslSet),
Marshal.SizeOf(configSslSet), kernel3232: ActivateActCtx
public int cbSize;
actCtx.cbSize = Marshal.SizeOf(typeof(ACTCTX)); 33: APIGetVersionEx
public uint dwOSVersionInfoSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
Public dwOSVersionInfoSize As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> _
osv.dwOSVersionInfoSize = Marshal.SizeOf(osv)
osv.dwOSVersionInfoSize = Marshal.SizeOf(osv)
don't forget to set the dwOSVersionInfoSize
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(osVersionInfo); // don't forget this line, please! 34: ConsoleFunctions
// http://pinvoke.net/default.aspx/kernel32/GetConsoleFontSize.html
static extern COORD GetConsoleFontSize(
uint Size
uint nSize
// http://pinvoke.net/default.aspx/kernel32/GetLargestConsoleWindowSize.html
static extern COORD GetLargestConsoleWindowSize(
COORD dwBufferSize,
// http://pinvoke.net/default.aspx/kernel32/SetConsoleScreenBufferSize.html
static extern bool SetConsoleScreenBufferSize(
COORD dwSize
COORD dwBufferSize,
public COORD dwSize;
public COORD dwMaximumWindowSize;
public uint cbSize;
public COORD dwSize;
public COORD dwMaximumWindowSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
return new CONSOLE_SCREEN_BUFFER_INFO_EX { cbSize = 96 };
public COORD dwFontSize;
public uint cbSize;
public COORD dwFontSize;
fixed char FaceName[LF_FACESIZE];
const uint LF_FACESIZE = 32;
public WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
public struct WINDOW_BUFFER_SIZE_RECORD
public COORD dwSize;
public WINDOW_BUFFER_SIZE_RECORD(short x, short y)
dwSize = new COORD();
dwSize.X = x;
dwSize.Y = y;
uint Size;
ushort cbSize;
ushort HistoryBufferSize; 35: CopyFile
long TotalFileSize,
long StreamSize,
private CopyProgressResult CopyProgressHandler(long total, long transferred, long streamSize, long StreamByteTrans, uint dwStreamNumber,CopyProgressCallbackReason reason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData)
Private Delegate Function CopyProgressRoutine(ByVal TotalFileSize As Long, _
ByVal TotalBytesTransferred As Long, ByVal StreamSize As Long, ByVal StreamBytesTransferred As Long, _
Private Function CopyProgressHandler(ByVal total As Long, ByVal transferred As Long, ByVal streamSize As Long, ByVal StreamByteTrans As Long, ByVal dwStreamNumber As UInteger, ByVal reason As CopyProgressCallbackReason, _ 36: CopyFileEx
long TotalFileSize,
long StreamSize,
private CopyProgressResult CopyProgressHandler(long total, long transferred, long streamSize, long StreamByteTrans, uint dwStreamNumber,CopyProgressCallbackReason reason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData)
Private Delegate Function CopyProgressRoutine(ByVal TotalFileSize As Long, _
ByVal TotalBytesTransferred As Long, ByVal StreamSize As Long, ByVal StreamBytesTransferred As Long, _
Private Function CopyProgressHandler(ByVal total As Long, ByVal transferred As Long, ByVal streamSize As Long, ByVal StreamByteTrans As Long, ByVal dwStreamNumber As UInteger, ByVal reason As CopyProgressCallbackReason, _ 37: CreateFiber
static extern IntPtr CreateFiber(uint dwStackSize, 38: CreateFile
uint dwMaximumSizeHigh,
uint dwMaximumSizeLow,
dwMaximumSizeHigh As UInteger, _
dwMaximumSizeLow As UInteger, _
Int64 MapViewSize = (AtOffset % _AllocationGranularity) + _AllocationGranularity;
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapWrite, FileMapStart, (Int32)MapViewSize);
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(p, MapViewSize, MapViewSize, FileAccess.Write);
Win32API.FlushViewOfFile(hMVF, (Int32)MapViewSize);
Int64 MapViewSize = (AtOffset % _AllocationGranularity) + _AllocationGranularity;
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapRead, FileMapStart, (Int32)MapViewSize);
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(p, MapViewSize, MapViewSize, FileAccess.Read);
Int64 MapViewSize = (AtOffset % _AllocationGranularity) + _AllocationGranularity;
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapWrite, FileMapStart, (Int32)MapViewSize);
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(p, MapViewSize, MapViewSize, FileAccess.Write);
Win32API.FlushViewOfFile(hMVF, (Int32)MapViewSize);
Int64 MapViewSize = (AtOffset % _AllocationGranularity) + _AllocationGranularity;
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapRead, FileMapStart, (Int32)MapViewSize);
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(p, MapViewSize, MapViewSize, FileAccess.Read);
/// returns the streamed size of an object
public long Size(Object T)
private static extern IntPtr CreateFileMapping(IntPtr hFile, IntPtr lpAttributes, FileMapProtection flProtect, Int32 dwMaxSizeHi, Int32 dwMaxSizeLow, string lpName);
internal static IntPtr CreateFileMapping(System.IO.FileStream File, FileMapProtection flProtect, Int64 ddMaxSize, string lpName)
int Hi = (Int32)(ddMaxSize / Int32.MaxValue);
int Lo = (Int32)(ddMaxSize % Int32.MaxValue);
public uint dwPageSize;
uint dwMaximumSizeHigh,
uint dwMaximumSizeLow,
dwMaximumSizeHigh As UInteger, _
dwMaximumSizeLow As UInteger, _
Int64 MapViewSize = (AtOffset % _AllocationGranularity) + _AllocationGranularity;
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapWrite, FileMapStart, (Int32)MapViewSize);
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(p, MapViewSize, MapViewSize, FileAccess.Write);
Win32API.FlushViewOfFile(hMVF, (Int32)MapViewSize);
Int64 MapViewSize = (AtOffset % _AllocationGranularity) + _AllocationGranularity;
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapRead, FileMapStart, (Int32)MapViewSize);
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(p, MapViewSize, MapViewSize, FileAccess.Read);
Int64 MapViewSize = (AtOffset % _AllocationGranularity) + _AllocationGranularity;
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapWrite, FileMapStart, (Int32)MapViewSize);
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(p, MapViewSize, MapViewSize, FileAccess.Write);
Win32API.FlushViewOfFile(hMVF, (Int32)MapViewSize);
Int64 MapViewSize = (AtOffset % _AllocationGranularity) + _AllocationGranularity;
hMVF = Win32API.MapViewOfFile(_hMMF, Win32API.FileMapAccess.FileMapRead, FileMapStart, (Int32)MapViewSize);
UnmanagedMemoryStream ums = new UnmanagedMemoryStream(p, MapViewSize, MapViewSize, FileAccess.Read);
/// returns the streamed size of an object
public long Size(Object T)
private static extern IntPtr CreateFileMapping(IntPtr hFile, IntPtr lpAttributes, FileMapProtection flProtect, Int32 dwMaxSizeHi, Int32 dwMaxSizeLow, string lpName);
internal static IntPtr CreateFileMapping(System.IO.FileStream File, FileMapProtection flProtect, Int64 ddMaxSize, string lpName)
int Hi = (Int32)(ddMaxSize / Int32.MaxValue);
int Lo = (Int32)(ddMaxSize % Int32.MaxValue);
public uint dwPageSize; 40: CreateMailslot
static extern IntPtr CreateMailslot(string lpName, uint nMaxMessageSize,
ByVal nMaxMessageSize As UInt32, _ 41: CreateMutex
public byte size;
secAttribs.nLength = Marshal.SizeOf( secAttribs );
securityDescPtr = Marshal.AllocCoTaskMem( Marshal.SizeOf( securityDesc ) );
mutexAttributesPtr = Marshal.AllocCoTaskMem( Marshal.SizeOf( secAttribs ) ); 42: CreateNamedPipe
uint dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize,
uint dwPipeMode, uint nMaxInstances, uint nOutBufferSize, uint nInBufferSize,
uint nOutBufferSize, // output buffer size
uint nInBufferSize, // input buffer size
byte[] buffer, uint nBufferSize, ref uint bytesRead, 43: CreatePipe
ref SECURITY_ATTRIBUTES lpPipeAttributes, uint nSize);
Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize As Long) As Long 44: CreateProcess
pSec.nLength = Marshal.SizeOf(pSec);
tSec.nLength = Marshal.SizeOf(tSec);
pSec.nLength = Marshal.SizeOf(pSec)
tSec.nLength = Marshal.SizeOf(tSec)
IntPtr lpThreadAttributes, uint dwStackSize, ThreadStartDelegate
IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress,
static def CreateRemoteThread(hProcess as IntPtr, lpThreadAttributes as IntPtr, dwStackSize as int, lpStartAddress as IntPtr, lpParameter as IntPtr, dwCreationFlags as uint, ref lpThreadId as int) as IntPtr: 46: CreateThread Warning: All signatures on this page are wrong as of 2014-01-24. dwStackSize is SIZE_T and ThreadStart has the wrong delegate signature. It only works by coincidence.
uint dwStackSize,
unsafe uint StartThread(StartThread ThreadFunc, int StackSize)
uint dwHandle = CreateThread(null, (uint)StackSize, ThreadFunc, lpParam, 0, out lpThreadID);
SecurityAttributes, uint StackSize, System.Threading.ThreadStart StartFunction,
internal UInt32 dwSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
procEntry.dwSize = (UInt32)Marshal.SizeOf(typeof(PROCESSENTRY32)); 48: DeviceIoControl
IntPtr lpInBuffer, uint nInBufferSize,
IntPtr lpOutBuffer, uint nOutBufferSize,
int nInBufferSize,
int nOutBufferSize,
uint nInBufferSize,
uint nOutBufferSize,
Shared Function DeviceIoControl(ByVal hDevice As IntPtr, ByVal dwIoControlCode As UInteger, ByVal lpInBuffer As IntPtr, ByVal nInBufferSize As UInteger, ByVal lpOutBuffer As IntPtr, ByVal nOutBufferSize As UInteger, ByRef lpBytesReturned As UInteger, ByVal lpOverlapped As IntPtr) As Boolean
ByVal nInBufferSize As Integer, ByRef OutBuffer As Long, _
ByVal nOutBufferSize As Integer, ByRef pBytesReturned As Integer, _
ByVal nInBufferSize As UInteger, <MarshalAs(UnmanagedType.AsAny), _
Out()> ByVal OutBuffer As Object, ByVal nOutBufferSize As UInteger, _
public bool DeviceIoControl( IntPtr hDevice, uint dwIoControlCode, ref long buffer, int bufferSize, ref NativeOverlapped pOverlapped)
return DeviceIoControl( hDevice, dwIoControlCode, ref buffer, bufferSize, ref buffer, bufferSize, ref NoReturn, ref pOverlapped );
IntPtr.Zero, 0, out diskGeo, Marshal.SizeOf(diskGeo), out dummy, IntPtr.Zero);
IntPtr.Zero, 0, out partInfo, Marshal.SizeOf(partInfo), out dummy, IntPtr.Zero);
if (length != len) Array.Resize(ref data, len);
DiskUpdateDriveSize = (EFileDevice.Disk << 16) | (0x0032 << 2) | EMethod.Buffered | (FileAccess.ReadWrite << 14),
uint nInBufferSize,
uint nOutBufferSize,
mPtrOverlapped = Marshal.AllocHGlobal(Marshal.SizeOf(typeof (NativeOverlapped)));
DeviceIoControl(hDevice, iCtlCode, inBuffer, inSize, outBuffer, outSize, out ret, deviceIoOverlapped.GlobalOverlapped)
Public Const READ_ATTRIBUTE_BUFFER_SIZE As Integer = 512
Public Const IDENTIFY_BUFFER_SIZE As Integer = 512
Public Const READ_THRESHOLD_BUFFER_SIZE As Integer = 512
Public Const OUTPUT_DATA_SIZE As Integer = IDENTIFY_BUFFER_SIZE + 16
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Integer, ByVal dwIoControlCode As Integer, ByRef lpInBuffer As IntPtr, ByVal nInBufferSize As Integer, ByRef lpOutBuffer As IntPtr, ByVal nOutBufferSize As Integer, ByRef lpBytesReturned As Integer, ByVal lpOverlapped As IntPtr) As Integer
Private Declare Ansi Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Integer, ByVal dwIoControlCode As Integer, ByVal lpInBuffer As Integer, ByVal nInBufferSize As Integer, ByRef lpOutBuffer As Integer, ByVal nOutBufferSize As Integer, ByRef lpBytesReturned As Integer, ByVal lpOverlapped As Integer) As Integer
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Integer, ByVal dwIoControlCode As Integer, ByRef lpInBuffer As IntPtr, ByVal nInBufferSize As Integer, ByRef lpOutBuffer As DISK_GEOMETRY, ByVal nOutBufferSize As Integer, ByRef lpBytesReturned As Integer, ByVal lpOverlapped As IntPtr) As Integer
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Integer, ByVal dwIoControlCode As Integer, ByRef lpInBuffer As IntPtr, ByVal nInBufferSize As Integer, ByRef lpOutBuffer As GETVERSIONOUTPARAMS, ByVal nOutBufferSize As Integer, ByRef lpBytesReturned As Integer, ByVal lpOverlapped As IntPtr) As Integer
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Integer, ByVal dwIoControlCode As Integer, ByRef lpInBuffer As SENDCMDINPARAMS, ByVal nInBufferSize As Integer, ByRef lpOutBuffer As IntPtr, ByVal nOutBufferSize As Integer, ByRef lpBytesReturned As Integer, ByVal lpOverlapped As IntPtr) As Integer
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> _
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> _
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=19)> _
Dim wBufferSize As Short
Dim wECCSize As Short
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=7)> _
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=39)> _
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=127)> _
Dim cBufferSize As Integer ' Buffer size in bytes
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=3)> _
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> _
Public dwOSVersionInfoSize As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> _
Dim bArrOut(OUTPUT_DATA_SIZE - 1) As Byte
For i = 0 To OUTPUT_DATA_SIZE - 1
.cBufferSize = IDENTIFY_BUFFER_SIZE
Dim arraySize As Integer = bArrOut.Length
Dim buffer As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(arraySize) * bArrOut.Length)
If DeviceIoControl(hdrive, DFP_RECEIVE_DRIVE_DATA, SCIP, 32, buffer, OUTPUT_DATA_SIZE, lpcbBytesReturned, IntPtr.Zero) Then
Marshal.Copy(buffer, bArrOut, 0, arraySize)
[Out] StringBuilder ComputerName, ref uint nSize);
ref uint nSize); Returns ERROR_SUCCESS on success or an error code on failure. Unless only the primary computer name is requested, the buffer will be filled with a series of null-terminated strings followed by a final null terminator. To measure the required number of characters, not including the final null terminator, use a null buffer and a zero size. This function is similar to GetComputerNameEx, and delegates to it to obtain the primary computer name.
LOCALE_IPAPERSIZE =0x0000100A, // 1 = letter, 5 = legal, 8 = a3, 9 = a4
LOCALE_IPAPERSIZE =0x0000100A, // 1 = letter, 5 = legal, 8 = a3, 9 = a4
public static extern int ExpandEnvironmentStrings([MarshalAs(UnmanagedType.LPTStr)] String source, [Out] StringBuilder destination, int size);
nSize As integer ) As Integer
Public Declare Function ExpandEnvironmentStrings Lib "kernel32.dll" Alias "ExpandEnvironmentStringsW" (ByVal lpSrc As String, ByVal lpDst As String, ByVal nSize As Long) As Long FILE_NOTIFY_CHANGE_SIZE 0x00000008
UIntPtr dwSize);
Shared Function FlushInstructionCache(hProcess As IntPtr, lpBaseAddress As IntPtr, dwSize As UIntPtr) As Boolean
uint nSize, IntPtr Arguments);
uint nSize, IntPtr pArguments);
uint nSize, string[] Arguments);
static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, [Out] StringBuilder lpBuffer, uint nSize, string[] Arguments);
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByRef lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As [String], ByVal nSize As Integer, ByRef Arguments As IntPtr) As Integer
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByVal lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, <MarshalAs(UnmanageType.LPWStr)> ByRef lpBuffer As String, ByVal nSize As Integer, ByVal Arguments As IntPtr) As Integer
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByVal lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As StringBuilder, ByVal nSize As Integer, ByVal Arguments As IntPtr) As Integer 57: FormatMessage
uint nSize, IntPtr Arguments);
uint nSize, IntPtr pArguments);
uint nSize, string[] Arguments);
static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, [Out] StringBuilder lpBuffer, uint nSize, string[] Arguments);
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByRef lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As [String], ByVal nSize As Integer, ByRef Arguments As IntPtr) As Integer
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByVal lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, <MarshalAs(UnmanageType.LPWStr)> ByRef lpBuffer As String, ByVal nSize As Integer, ByVal Arguments As IntPtr) As Integer
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByVal lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As StringBuilder, ByVal nSize As Integer, ByVal Arguments As IntPtr) As Integer
Public Shared Function FormatMessage(ByVal dwFlags As Integer, ByRef lpSource As IntPtr, ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, ByRef lpBuffer As IntPtr, ByVal nSize As Integer, ByRef Arguments As IntPtr) As Integer 58: GetAtomName
static extern uint GetAtomName(ushort nAtom, [Out] StringBuilder lpBuffer, int nSize); 59: GetCommConfig
ref uint lpdwSize);
static extern uint GetCompressedFileSize(string lpFileName,
out uint lpFileSizeHigh);
Private Declare Function GetCompressedFileSize Lib "kernel32" Alias "GetCompressedFileSizeA" (ByVal lpFileName As String, ByVal lpFileSizeHigh As IntPtr) As UInt32
Private Declare Function GetCompressedFileSize Lib "kernel32" Alias "GetCompressedFileSizeA" (ByVal lpFileName As String, lpFileSizeHigh As Long) As Long The code below correctly obtains the compressed file size also if above 4GB. (Fixed VB and C# code, 2012 Eske Rahn)
[DllImport("kernel32.dll", SetLastError=true, EntryPoint="GetCompressedFileSize")]
static extern uint GetCompressedFileSizeAPI(string lpFileName, out uint lpFileSizeHigh);
public ulong GetCompressedFileSize(string filename)
low = GetCompressedFileSizeAPI(filename, out high);
Public Function CompressedFileSize(ByVal path As String) As Long
' Return Convert.ToInt64(GetCompressedFileSize(path, IntPtr.Zero))
Dim filelength as Long = Convert.ToInt64(GetCompressedFileSize(path, ptr))
If Err <> 0 Then Throw New IOException("Exception getting compressed size: " & Err.ToString)
Throw New IOException("The compressed size of the specified file could not be determined.")
Private Sub GetFileSize(ByVal strPath As String)
MsgBox "The size of " + strPath " is " + CStr(GetCompressedFileSize(strPath, ByVal 0&)) + " bytes " Cut off search results after 60. Please refine your search. |