我用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入口这个是什么原因?
[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、Dll中没有这个函数。
2、参数情你搞错了!
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没问题的。看看是不是调用的问题。
Form1::Main+0xa"确定"将终止