Desktop Functions: Smart Device Functions:
|
Search Results for "SIZE" in [All]dwmapi
public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size);
Public Shared Sub DwmQueryThumbnailSourceSize(ByVal hThumbnail as IntPtr, ByRef size as Size); None (Size is System.Drawing.Size) The function populates the Size structure with the size of the requested window. 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); cards3: cdtDraw
4: cdtDrawExt
msvcrt5: fwrite
static extern IntPtr fwrite(byte[] buffer, IntPtr size, IntPtr number, IntPtr file);
Declare Function fwrite Lib "msvcrt.dll" (byte[] buffer, IntPtr size, IntPtr number, IntPtr file) As IntPtr 6: memcmp
7: memcpy
Dim size As Integer = Marshal.SizeOf(managedArray1(0)) * managedArray1.Length
Dim pnt1 As IntPtr = Marshal.AllocHGlobal(size)
Dim pnt2 As IntPtr = Marshal.AllocHGlobal(size)
CopyMemory(pnt2, pnt1, size * 2)
// get source image size 8: _pipe
static extern int _pipe(int[] pfds, uint psize, int textmode); 9: _stat
public uint st_size; ntdll10: NtCreateFile
public static extern int NtCreateFile(out SafeFileHandle handle, FileAccess access, OBJECT_ATTRIBUTES* objectAttributes, IO_STATUS_BLOCK* ioStatus, ref long allocSize, uint fileAttributes, FileShare share, uint createDisposition, uint createOptions, IntPtr eaBuffer, uint eaLength);
ref long allocSize,
long allocSize = 0;
IntPtr objAttIntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(objAttributes));
objAttributes.Length = System.Convert.ToInt32(Marshal.SizeOf(objAttributes));
ref allocSize,
p_fbi = Marshal.AllocHGlobal(Marshal.SizeOf(fbi));
IntPtr iprc = NtQueryInformationFile(fs.SafeFileHandle, ref iosb, p_fbi, (uint)Marshal.SizeOf(fbi), FILE_INFORMATION_CLASS.FileBasicInformation);
ref PROCESS_BASIC_INFORMATION pbi, int cb, out int pSize);
IntPtr pbi = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(PROCESS_BASIC_INFORMATION)));
IntPtr outLong = Marshal.AllocHGlobal(sizeof(long));
queryStatus = NtQueryInformationProcess(hProc, 0, pbi, (uint)Marshal.SizeOf(typeof(PROCESS_BASIC_INFORMATION)), outLong);
int sizeInfoReturned;
int queryStatus = NtQueryInformationProcess(hProc, (PROCESSINFOCLASS)0, ref pbi, pbi.Size, out sizeInfoReturned); 13: NtQueryObject
infoLength = (uint)Marshal.SizeOf(typeof(uint));
/// <param name="Size">The allocation size of the buffer pointed to by Info</param>
/// <param name="Length">If null, ignored. Otherwise tells you the size of the information returned by the kernel.</param>
public static extern NtStatus NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS InfoClass, IntPtr Info, uint Size, out uint Length);
returnSize;
result = (UInt32)NativeMethods.NtQuerySystemInformation(NativeMethods.SYSTEM_INFORMATION_CLASS.SystemMemoryListInformation, buff, result, out returnSize);
if (NativeMethods.SYSTEM_MEMORY_LIST_INFORMATION_SIZE == 0)
NativeMethods.SYSTEM_MEMORY_LIST_INFORMATION_SIZE = returnSize; 15: PROCESSINFOCLASS
ProcessLdtSize,
ProcessHandleTracing, // q: PROCESS_HANDLE_TRACING_QUERY; s: size 0 disables, otherwise enables 16: RtlInitializeSid
[StructLayout(LayoutKind.Sequential, Size = 6)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public struct SYSTEM_MEMORY_LIST_INFORMATION // Size=88
public UInt32 ZeroPageCount; // Size=4 Offset=0
public UInt32 FreePageCount; // Size=4 Offset=4
public UInt32 ModifiedPageCount; // Size=4 Offset=8
public UInt32 ModifiedNoWritePageCount; // Size=4 Offset=12
public UInt32 BadPageCount; // Size=4 Offset=16
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public UInt32[] PageCountByPriority; // Size=32 Offset=20
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public UInt32[] RepurposedPagesByPriority; // Size=32 Offset=52
public UInt32 ModifiedPageCountPageFile; // Size=4 Offset=84
returnSize;
result = (UInt32)NativeMethods.NtQuerySystemInformation(NativeMethods.SYSTEM_INFORMATION_CLASS.SystemMemoryListInformation, buff, result, out returnSize); mpr
public int dwOptDataSize;
ci.cbStructure = Marshal.SizeOf(ci); 19: WNetEnumResource
public static extern uint WNetEnumResource(IntPtr hEnum, ref int lpcCount, IntPtr lpBuffer, ref uint lpBufferSize);
Public Shared Function WNetEnumResource(hEnum As IntPtr, ByRef lpcCount As Integer, lpBuffer As IntPtr, ByRef lpBufferSize As UInteger) As UInteger
ref int lpBufferSize );
ptr += Marshal.SizeOf( nr );
Public Function WNetEnumResource(ByVal hEnum As IntPtr, ByRef lpcCount As Integer, ByVal lpBuffer As IntPtr, ByRef lpBufferSize As Integer) As Integer
ptr += Marshal.SizeOf(nr)
ptr += Marshal.SizeOf(nr)
ptr += Marshal.SizeOf(nr) If the call fails because the StringBuilder is not large enough, the call will return a value of 234, and the Length parameter will contain the required size. // Size for the buffer we will use int bsize=200; // Create a new stringbuilder, pre-sized as above StringBuilder rname = new StringBuilder(bsize); rc = WNetGetConnection("p:", rname, ref bsize); 21: WNetGetLastError
static extern TODO WNetGetLastErrorA(ref int lpError,ref string lpErrorBuf,int nErrorBufSize,string lpNameBuf,int nNameBufSize); Or you can initialize a stringbuilder with a given size: public static extern uint WNetGetLastError(ref int lpError,StringBuilder lpErrorBuf,int nErrorBufSize,StringBuilder lpNameBuf,int nNameBufSize); Declare Function WNetGetLastError Lib "mpr.dll" Alias "WNetGetLastErrorA" (ByRef lpError As Integer, ByVal lpErrorBuf As String, ByVal nErrorBufSize As Integer, ByVal lpNameBuf As String, ByVal nNameBufSize As Integer) As Integer
string lpBufferSize, powrprof
UInt32 nInputBufferSize,
UInt32 nOutputBufferSize
Private Shared Function CallNtPowerInformation(InformationLevel As Int32, lpInputBuffer As IntPtr, nInputBufferSize As UInt32, lpOutputBuffer As IntPtr, nOutputBufferSize As UInt32) As UInt32
IntPtr status = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(SYSTEM_BATTERY_STATE)));
(UInt32)Marshal.SizeOf(typeof(SYSTEM_BATTERY_STATE))
int nInputBufferSize,
int nOutputBufferSize
procInfo.Length * Marshal.SizeOf(typeof(PROCESSOR_POWER_INFORMATION))
static extern bool DevicePowerEnumDevices(uint queryIndex, QueryInterpretationFlags queryInterpretationFlags, QueryFlags queryFlags, IntPtr pReturnBuffer, ref uint pBufferSize); If pReturnBuffer is NULL, pBufferSize will be filled with the size needed to return the data.
uint size = MAX_PATH;
IntPtr ptrBuffer = Marshal.AllocHGlobal((int)size);
(result = DevicePowerEnumDevices(index, QueryInterpretationFlags.DEVICEPOWER_FILTER_DEVICES_PRESENT, QueryFlags.PDCAP_D2_SUPPORTED, ptrBuffer, ref size)) != false) 25: PowerEnumerate
ref uint BufferSize);
ByRef BufferSize As UInteger) As UInteger
uint BufferSize = 16;
ReadBuffer = Marshal.AllocHGlobal((int)BufferSize);
ReturnCode = PowerEnumerate(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, PowerDataAccessor.ACCESS_SCHEME, Index, ReadBuffer, ref BufferSize);
uint buffSize = 0;
res = PowerReadFriendlyName(IntPtr.Zero, ptrActiveGuid, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ref buffSize);
IntPtr ptrName = Marshal.AllocHGlobal((int)buffSize);
res = PowerReadFriendlyName(IntPtr.Zero, ptrActiveGuid, IntPtr.Zero, IntPtr.Zero, ptrName, ref buffSize);
ref UInt32 BufferSize);
ref UInt32 BufferSize);
Buffer As IntPtr, ByRef BufferSize As UInteger) As UInteger
''' <param name="Buffer">A pointer to a buffer that receives the friendly name. If this parameter is NULL, the BufferSize parameter receives the required buffer size</param>
''' <param name="BufferSize">Size of the buffer.</param>
''' If the buffer size passed in the BufferSize parameter is too small, or if the Buffer parameter is NULL,
''' ERROR_MORE_DATA will be returned and the DWORD pointed to by the BufferSize parameter will be filled in with
''' the required buffer size.</returns>
uint buffSize = 0;
res = PowerReadFriendlyName(IntPtr.Zero, ptrActiveGuid, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ref buffSize);
if (buffSize == 0u) return "";
IntPtr ptrName = Marshal.AllocHGlobal((int)buffSize);
res = PowerReadFriendlyName(IntPtr.Zero, ptrActiveGuid, IntPtr.Zero, IntPtr.Zero, ptrName, ref buffSize);
IntPtr pRecipient = Marshal.AllocHGlobal(Marshal.SizeOf(recipient));
UInt32 BufferSize);
uint BufferSize = (uint)System.Text.ASCIIEncoding.Unicode.GetByteCount(name);
uint set = NativeMethods.PowerWriteFriendlyName(IntPtr.Zero, ref powerPlanId, IntPtr.Zero, IntPtr.Zero, name, BufferSize); kernel3230: ActivateActCtx
public int cbSize;
actCtx.cbSize = Marshal.SizeOf(typeof(ACTCTX)); 31: 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! 32: 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; 33: 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, _ 34: 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, _ 35: CreateFiber
static extern IntPtr CreateFiber(uint dwStackSize, 36: 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; 38: CreateMailslot
static extern IntPtr CreateMailslot(string lpName, uint nMaxMessageSize,
ByVal nMaxMessageSize As UInt32, _ 39: CreateMutex
public byte size;
secAttribs.nLength = Marshal.SizeOf( secAttribs );
securityDescPtr = Marshal.AllocCoTaskMem( Marshal.SizeOf( securityDesc ) );
mutexAttributesPtr = Marshal.AllocCoTaskMem( Marshal.SizeOf( secAttribs ) ); 40: 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, 41: 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 42: 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: 44: 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)); 46: 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 55: 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 56: GetAtomName
static extern uint GetAtomName(ushort nAtom, [Out] StringBuilder lpBuffer, int nSize); 57: 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 " 59: GetComputerName
StringBuilder lpBuffer, ref uint lpnSize);
Private Shared Function GetComputerNameEx(ByVal NameType As COMPUTER_NAME_FORMAT, ByVal lpBuffer As StringBuilder, ByRef lpnSize As UInt32) As Boolean
StringBuilder lpBuffer, ref uint lpnSize);
uint size = 260;
success = GetComputerNameEx(COMPUTER_NAME_FORMAT.ComputerNameDnsDomain, name, ref size);
StringBuilder lpBuffer, ref uint lpnSize);
Private Shared Function GetComputerNameEx(ByVal NameType As COMPUTER_NAME_FORMAT, ByVal lpBuffer As StringBuilder, ByRef lpnSize As UInt32) As Boolean
out StringBuilder lpBuffer, ref uint lpnSize);
uint size = 260;
success = GetComputerNameEx(COMPUTER_NAME_FORMAT.ComputerNameDnsDomain, name, ref size); Cut off search results after 60. Please refine your search. |