我用C#调用API打开串口:
[DllImport("coredll")] 
private static extern int CreateFile( 
string lpFileName, // file name 
uint dwDesiredAccess, // access mode 
int dwShareMode, // share mode 
int lpSecurityAttributes, // SD 
int dwCreationDisposition, // how to create 
int dwFlagsAndAttributes, // file attributes 
int hTemplateFile // handle to template file 
); 然后在下面打开串口函数调用CreateFile程序执行时错误:无法找到DLL coredll.dll 的CreateFile入口这个是什么原因?

解决方案 »

  1.   

    应该是coredll.dll里面没有CreateFile这个方法吧也有可能是[DllImport("coredll")] 写错了
      

  2.   

    CreateFile不是在kernel32.dll里面吗,再说,要指定是函数的字符集属性
      

  3.   

    [DllImport("coredll",EntryPoint="指定函数的入口点")]
      

  4.   

    这个问题有两种情况:
    1、Dll中没有这个函数。
    2、参数情你搞错了!
      

  5.   

    zhouhongyun(最终幻想)请问一下wince下能否调用kernel32.dll
      

  6.   

    对应的就是coredll。例如:
    public const int SW_SHOW = 5;
    public const int SW_HIDE = 0;
    [DllImport("coredll", EntryPoint = "ShowWindow")]
    public static extern int ShowWindow(
            int hwnd,
            int nCmdShow
            );CreateFile没问题的。看看是不是调用的问题。
      

  7.   

    但是在wince下面运行会出现这个错误:是什么原因呢一个托管的NullReferenceException发生在Application::Run+0x1aApplication::Run+0x1a
    Form1::Main+0xa"确定"将终止
      

  8.   

    因为你打开的时候有错误,看看NetCF 1.1源码,里面有你要的源码。