See this webpage
http://stackoverflow.com/questions/6972437/pinvoke-for-getlogicalprocessorinformation-function
The GetLogicalProcessorInformation is a function in the kernel32 library. You could be getting the error because the parameters you are passing the function do not meet the definition. The first parameter is a buffer and the second parameter
is the length of the buffer. if you are using windows 7 which is x64 the entry point may be different.
[DllImport(@"kernel32.dll",
SetLastError=true)]
public static extern bool
GetLogicalProcessorInformation(
IntPtr Buffer,
ref uint
ReturnLength
);
In the webpage the function is called twice. the first time with IntPtr.Zero and returns the length of the buffer the function requires. then the code uses Allocate to get the appropriate size bufffer and then calls the function a second
time with a pointer to the allocated buffer.
GetLogicalProcessorInformation(IntPtr.Zero, ref ReturnLength);
if (Marshal.GetLastWin32Error() == ERROR_INSUFFICIENT_BUFFER)
{
IntPtr Ptr = Marshal.AllocHGlobal((int)ReturnLength);
try
{
if (GetLogicalProcessorInformation(Ptr, ref ReturnLength))
jdweng