Error when importing system dll
I am receiving this error when trying to import a system dll.
Quote:
error CS0246: The type or namespace name 'sysimport' could not be found (are you missing a using directive or assembly reference?)
here is my code the line with the error is in red.
Code:
// Calling out a Win32 API function
using System;
using System.Runtime.InteropServices;
class CH4_14
{
[System.Runtime.InteropServices.StructLayoutAttribute
(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct _SYSTEM_INFO
{
public int dw0emID;
public int dwPageSize;
public int lpMinimumApplicationAdress;
public int lpMaximumApplicationAddress;
public int dwActiveProcessorMask;
public int dwNumberOfProcessors;
public int dwProcessorType;
public int dwAllocationGranularity;
public short wProcessorLevel;
public short wProcessorRevision;
}
[sysimport(dll="Kernel32.dll")]
unsafe private static extern void
GetSystemInfo([marshal(UnmanagedType.LPVoid)]uint* bufptr);
public static unsafe void Main()
{
try
{
_SYSTEM_INFO si = new _SYSTEM_INFO();
GetSystemInfo((uint*)&si);
Console.WriteLine("Processor Type = {0}", si.dwProcessorType);
Console.WriteLine("Number of Processors = {0}", si.dwNumberOfProcessors);
Console.WriteLine("Processor Level = {0}", si.wProcessorLevel);
Console.WriteLine("Processor Revision = {0}", si.wProcessorRevision);
}
catch(Exception e)
{
Console.WriteLine("Exception Caught! {0}", e);
}
}
}