Hi
I write a POS (point-of-sale) applic. until now i use c# code to open
the cash-drawer.
But now there is a new hardware and i have just a c++ code snip to do
this.
Please can somebody help me to translate this:
#include <windows.h>
// szDeviceName ->Device Driver Name
// CTL_ID-> Control Code
__declspec( dllimport ) DWORD WINAPI DeviceControl(LPSTR szDeviceName,
DWORD CTL_ID);
__declspec( dllimport ) DWORD WINAPI PortwellGetCashDrawerStatus(LPSTR
szDeviceName,DWORD CTL_ID);
void main()
{
DWORD ret; // 0 -> success, -1 -> create file
failed, -2 -> device io control failed
ret = DeviceControl("\\\\.\\FEC_cash", 10);
.....
ret = PortwellGetCashDrawerStatus("\\\\.\\FEC_cash", 11);
...
into C#
is LPSTR a byte[] ?
is DWORD = UInt32 ?
is "\\\\.\\FEC_cash" = @"\\.\FEC_cash"
Thank you
Peter
Nicholas Paldino [.NET/C# MVP] - 16 Oct 2007 14:24 GMT
Peter,
Here are your declarations that you will use:
[DllImport("dlllocation.dll")]
static extern int DeviceControl([MarshalAs(UnmanagedType.LPStr)] string
szDeviceName, int CTL_ID);
You have to replace "dlllocation.dll" with the name of the dll which the
functions are exported from. This dll has to be located by the LoadLibrary
function if it is not an absolute path. Additionally, if the functions call
SetLastError then you have to set the SetLastError property on the DllImport
attribute.
All of this applies to the PortwellGetCashDrawerStatus function as well.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hi
> I write a POS (point-of-sale) applic. until now i use c# code to open
[quoted text clipped - 31 lines]
> Thank you
> Peter
Peter - 16 Oct 2007 15:30 GMT
On 16 Okt., 15:24, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
> Peter,
>
[quoted text clipped - 53 lines]
>
> - Zitierten Text anzeigen -
Thank you.
Peter