Results 1 to 4 of 4

Thread: Error when importing system dll

Threaded View

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Error when importing system dll

    I am receiving this error when trying to import a system dll.
    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);
    		}
    	}
    }
    Last edited by Memnoch1207; Aug 14th, 2003 at 04:19 PM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width