A
Antoine
Hello,
I'm writing a program to send requests to my wlan pocket pc device (UIO1:
driver) in C#.
Here how I import CreateFile functions from coredll.dll with DllImport:
[DllImport("coredll.dll", SetLastError=true, CharSet=CharSet.Auto)]
public static extern IntPtr CreateFile(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr lpSecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile
);
[DllImport("coredll.dll", EntryPoint="CreateFileW", SetLastError = true,
CharSet=CharSet.Auto)]
private static extern IntPtr CreateFileW(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr lpSecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile
);
Then, I try to open the device with this code:
hMSD = CreateFileW( "UIO1:", GENERIC_READ|GENERIC_WRITE, 0,
System.IntPtr.Zero, OPEN_EXISTING, 0, System.IntPtr.Zero);
if( hMSD == new IntPtr(-1) || Marshal.GetLastWin32Error()>0)
{
System.Windows.Forms.MessageBox.Show( "ERROR
n"+Marshal.GetLastWin32Error(), "ERROR !",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Exclamation,
System.Windows.Forms.MessageBoxDefaultButton.Button1);
throw(new ApplicationException( "ERROR
["+Marshal.GetLastWin32Error()+"]: opening port."));
}
I tried to open device with CreateFile() and CECreateFileW() functions, but
none really succeeded.
* CreateFile() fails and GetLastWin32Error() returns 87 error code
(ERROR_INVALID_PARAMETER).
* CreateFileW() succeed with integrated POCKET PC 2003 EMULATOR but fails on
my Pocket PC 2003 (Windows CE 4.2) where GetLastWin32Error() returns 120
error code (ERROR_CALL_NOT_IMPLEMENTED).
Then, I tried to play with CharSet DllImport attribute, but with no success.
The same program wrote in C++ runs...
My english is poor, so I hope you understood my problem.
Thank you for you help.
Antoine.
I'm writing a program to send requests to my wlan pocket pc device (UIO1:
driver) in C#.
Here how I import CreateFile functions from coredll.dll with DllImport:
[DllImport("coredll.dll", SetLastError=true, CharSet=CharSet.Auto)]
public static extern IntPtr CreateFile(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr lpSecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile
);
[DllImport("coredll.dll", EntryPoint="CreateFileW", SetLastError = true,
CharSet=CharSet.Auto)]
private static extern IntPtr CreateFileW(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr lpSecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile
);
Then, I try to open the device with this code:
hMSD = CreateFileW( "UIO1:", GENERIC_READ|GENERIC_WRITE, 0,
System.IntPtr.Zero, OPEN_EXISTING, 0, System.IntPtr.Zero);
if( hMSD == new IntPtr(-1) || Marshal.GetLastWin32Error()>0)
{
System.Windows.Forms.MessageBox.Show( "ERROR
n"+Marshal.GetLastWin32Error(), "ERROR !",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Exclamation,
System.Windows.Forms.MessageBoxDefaultButton.Button1);
throw(new ApplicationException( "ERROR
["+Marshal.GetLastWin32Error()+"]: opening port."));
}
I tried to open device with CreateFile() and CECreateFileW() functions, but
none really succeeded.
* CreateFile() fails and GetLastWin32Error() returns 87 error code
(ERROR_INVALID_PARAMETER).
* CreateFileW() succeed with integrated POCKET PC 2003 EMULATOR but fails on
my Pocket PC 2003 (Windows CE 4.2) where GetLastWin32Error() returns 120
error code (ERROR_CALL_NOT_IMPLEMENTED).
Then, I tried to play with CharSet DllImport attribute, but with no success.
The same program wrote in C++ runs...
My english is poor, so I hope you understood my problem.
Thank you for you help.
Antoine.