Click here to Skip to main content
15,887,683 members
Articles / Mobile Apps
Article

Win32 API: C++ to .NET

Rate me:
Please Sign up or sign in to vote.
3.77/5 (40 votes)
8 Mar 200512 min read 393.2K   112   88
This is a conversion sheet to go from C++ API calls to .NET P/Invoke. It includes data type conversions and tips.

Introduction

I am writing an article to give a reference to developers who need to use API imports in their .NET programs to call C++ functions. I haven't found a single site that looks good or is totally complete with all the data types or has them converted correctly. So, I decided to write one. I also recommend using any new .NET function that does the same thing as an API if it is available. At least 75% of the API has already been converted to .NET and is available in various classes. This is because they usually work better and look nicer. If you have any questions send me an email or post them to the message board.

.NET API declaration form

VB.NET

VB
Declare Function <Name> Lib <dll name> <Optional fields> (<params>) _
                                                      As <return type>

C# definition

C#
[DllImport("<dll name>", <optional fields>)] 
        static extern <return type> <Method name> (<Params>)

Managed C++ .NET

MC++
[DllImport("<Dll name>",<optional fields>)]
     static <return type> <Function name>( <Params>);

Examples

Windows API reference for C#, VB.NET & VB6 - This site has every major API declaration for VB.NET, C#.NET and some VB6.

Here is a program I have made that uses these sites:

VB.NET

VB
Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA"(_
           ByVal dwFlags As Integer, ByRef lpSource As Object, _
           ByVal dwMessageId As Integer, ByVal dwLanguageId As Integer, _
           ByVal lpBuffer As String, ByVal nSize As Integer, _
           ByRef Arguments As Integer) As Integer

C# definition

C#
[DllImport("kernel32.dll", SetLastError=true)] 
   static extern int FormatMessageA ( int dwFlags, ref object lpSource, 
   int dwMessageId, int dwLanguageId, string lpBuffer, 
   int nSize, ref int Arguments)

Managed C++. NET

MC++
[DllImport("KERNEL32.DLL",EntryPoint="MoveFileW",
   SetLastError=true,CharSet=CharSet::Unicode,ExactSpelling=true,
   CallingConvention=CallingConvention::StdCall)]
   static bool MoveFile( String^ src, String^ dst );

Tips

  1. In this list, a pointer to a data type is represented like P, for example DWORD* = PDWORD.
  2. Some types like UIntPtr are not CLS compliant so I use IntPtr instead, but you can use any of these.
  3. The first choice that comes up after the "=" in the IDE’s Intellisense is the best choice usually.
  4. When using strings in COM Interop, for inputs you always use string for WCHAR*, TCHAR*, etc. For outputs you can use string or StringBuilder, but sometimes you need to use an IntPtr and marshal the characters out of it using Marshal.PtrToStructure() and increment the pointer till you get null characters. To increment a pointer turn it into an int and increase the size each time by the size of the type you get from Marshal.PtrToStructure() each time. E.g. : pointer += Marshal.SizeOf(<last object you got back>);
  5. Sometimes certain data types that aren't correct will work. E.g.: An int could be used for a uint.
  6. If you need to convert an IntPtr back to an int or some other class, use Marshal.PtrToStructure() or some other IntPtr method.
  7. If the API your using is dependent on ANSI or Unicode, make sure you select the correct one so that your strings will be formatted correctly. Look at the CharSet enumeration.
  8. Most of the API calls can be written in a managed declaration, but some need pointers, in C# you can use pointers if you surround the code with the unsafe keyword and use the /unsafe compiler option.
  9. If you want to make sure that the garbage collector doesn't eat your IntPtr in an API call you can use a HandleRef type.
  10. When you need to declare structs for API, make sure they have the StructLayout.Sequential attribute. Also sometimes you may need to change the packing on a struct to make it work right, but usually you don't.
  11. When passing or retrieving arrays to/from API methods, look if it's a pointer to an array or a direct input array, if it's a pointer you need to marshal it to an IntPtr possibly.
  12. Sometimes choosing the type to use can be hard but you'll get the hang of it after a few times.
  13. When I show the types to use for pointers to data types I say IntPtr or the data type it points to, sometimes you can just say ref <datatype> or out <datatype>, but unless it's an input char * you need to use IntPr for inputs and ref IntPtr for outputs.
  14. If your function declaration fails to work don't always blame it on the way you wrote declaration, it may be a call to the previous methods that messed it up, or just a bad data getting passed in.
  15. Use the Marshal and MarshalAs classes only when you have to, as they take up more processing power in certain situations.

Data type conversion sheet : C++ to .NET

Term

Description

ATOM

.NET = ushort

C++ = typedef WORD ATOM;

BOOL

.NET = bool or int

C++ = typedef int BOOL;

BOOLEAN

.NET = bool or byte

C++ = typedef BYTE BOOLEAN;

BYTE

.NET = byte

C++ = typedef unsigned char BYTE;

CALLBACK

.NET = delegate

C++ = #define CALLBACK __stdcall

CHAR

.NET = char

C++ = typedef char CHAR;

COLORREF

.NET = uint

C++ = typedef DWORD COLORREF;

CONST

.NET = const

C++ = #define CONST const

DWORD

.NET = uint

C++ = typedef unsigned long DWORD;

DWORDLONG

ulong

C++ = typedef ULONGLONG DWORDLONG;

DWORD_PTR

DWORD *

.NET = uint or IntPtr

C++ = typedef ULONG_PTR DWORD_PTR;

DWORD32

.NET = uint

C++ = typedef unsigned int DWORD32;

DWORD64

.NET = ulong

C++ = typedef unsigned __int64 DWORD64;

FLOAT

.NET = single

C++ = typedef float FLOAT;

HACCEL

.NET = IntPtr

C++ = typedef HANDLE HACCEL;

HANDLE

.NET = IntPtr

C++ = typedef PVOID HANDLE;

HBITMAP

.NET = IntPtr

C++ = typedef HANDLE HBITMAP;

HBRUSH

.NET = IntPtr

C++ = typedef HANDLE HBRUSH;

HCOLORSPACE

.NET = IntPtr

C++ = if(WINVER >= 0x0400)

C++ = typedef HANDLE HCOLORSPACE;

HCONV

.NET = IntPtr

C++ = typedef HANDLE HCONV;

HCONVLIST

.NET = IntPtr

C++ = typedef HANDLE HCONVLIST;

HCURSOR

.NET = IntPtr

C++ = typedef HICON HCURSOR;

HDC

.NET = IntPtr

C++ = typedef HANDLE HDC;

HDDEDATA

.NET = IntPtr

C++ = typedef HANDLE HDDEDATA;

HDESK

.NET = IntPtr

C++ = typedef HANDLE HDESK;

HDROP

.NET = IntPtr

C++ = typedef HANDLE HDROP;

HDWP

.NET = IntPtr

C++ = typedef HANDLE HDWP;

HENHMETAFILE

.NET = IntPtr

C++ = typedef HANDLE HENHMETAFILE;

HFILE

.NET = int

C++ = typedef int HFILE;

HFONT

.NET = IntPtr

C++ = typedef HANDLE HFONT;

HGDIOBJ

.NET = IntPtr

C++ = typedef HANDLE HGDIOBJ;

HGLOBAL

.NET = IntPtr

C++ = typedef HANDLE HGLOBAL;

HHOOK

.NET = IntPtr

C++ = typedef HANDLE HHOOK;

HICON

.NET = IntPtr

C++ = typedef HANDLE HICON;

HINSTANCE

.NET = IntPtr

C++ = typedef HANDLE HINSTANCE;

HKEY

.NET = IntPtr

C++ = typedef HANDLE HKEY;

HKL

.NET = IntPtr

C++ = typedef HANDLE HKL;

HLOCAL

.NET = IntPtr

C++ = typedef HANDLE HLOCAL;

HMENU

.NET = IntPtr

C++ = typedef HANDLE HMENU;

HMETAFILE

.NET = IntPtr

C++ = typedef HANDLE HMETAFILE;

HMODULE

.NET = IntPtr

C++ = typedef HINSTANCE HMODULE;

HMONITOR

.NET = IntPtr

if(WINVER >= 0x0500)

C++ = typedef HANDLE HMONITOR;

HPALETTE

.NET = IntPtr

C++ = typedef HANDLE HPALETTE;

HPEN

.NET = IntPtr

C++ = typedef HANDLE HPEN;

HRESULT

.NET = int or uint

C++ = typedef LONG HRESULT;

HRGN

.NET = IntPtr

C++ = typedef HANDLE HRGN;

HRSRC

.NET = IntPtr

C++ = typedef HANDLE HRSRC;

HSZ

.NET = IntPtr

C++ = typedef HANDLE HSZ;

HWINSTA

.NET = IntPtr

C++ = typedef HANDLE WINSTA;

HWND

.NET = IntPtr

C++ = typedef HANDLE HWND;

INT

.NET = int

C++ = typedef int INT;

INT_PTR

.NET = IntPtr

#if defined(_WIN64)

C++ = typedef __int64 INT_PTR;

#else

C++ = typedef int INT_PTR;

INT32

.NET = int

C++ = typedef signed int INT32;

INT64

.NET = long

C++ = typedef signed __int64 INT64;

LANGID

.NET = ushort or int

C++ = typedef WORD LANGID;

LCID

.NET = uint

C++ = typedef DWORD LCID;

LCTYPE

.NET = uint

C++ = typedef DWORD LCTYPE;

LGRPID

.NET = uint

C++ = typedef DWORD LGRPID;

LONG

.NET = int

C++ = typedef long LONG;

LONGLONG

.NET = long

#if !defined(_M_IX86)

C++ = typedef __int64 LONGLONG;

#else

C++ = typedef double LONGLONG;

LONG_PTR

.NET = IntPtr

#if defined(_WIN64)

C++ = typedef __int64 LONG_PTR;

#else

C++ = typedef long LONG_PTR;

LONG32

.NET = int

C++ = typedef signed int LONG32;

LONG64

.NET = long

C++ = typedef __int64 LONG64;

LPARAM

.NET = IntPtr

C++ = typedef LONG_PTR LPARAM;

LPBOOL

Bool *

.NET = IntPtr or bool

C++ = typedef BOOL *LPBOOL;

LPBYTE

Byte *

.NET = IntPtr or byte

C++ = typedef BYTE *LPBYTE;

LPCOLORREF

.NET = IntPtr or uint

C++ = typedef DWORD *LPCOLORREF;

LPCSTR

.NET = string or IntPtr or StringBuilder

C++ = typedef CONST CHAR *LPCSTR;

LPCTSTR

.NET = string or IntPtr or StringBuilder

#ifdef UNICODE

C++ = typedef LPCWSTR LPCTSTR;

#else

C++ = typedef LPCSTR LPCTSTR;

LPCVOID

.NET = IntPtr

C++ = typedef CONST void *LPCVOID;

LPCWSTR

.NET = string or IntPtr or StringBuilder

C++ = typedef CONST WCHAR *LPCWSTR;

LPDWORD

.NET = IntPtr or uint

C++ = typedef DWORD *LPDWORD;

LPHANDLE

.NET = IntPtr

C++ = typedef HANDLE *LPHANDLE;

LPINT

.NET = IntPtr or int

C++ = typedef int *LPINT;

LPLONG

.NET = IntPtr or int

C++ = typedef long *LPLONG;

LPSTR

.NET = string or IntPtr or StringBuilder

C++ = typedef CHAR *LPSTR;

LPTSTR

.NET = string or IntPtr or StringBuilder

#ifdef UNICODE

C++ = typedef LPWSTR LPTSTR;

#else

C++ = typedef LPSTR LPTSTR;

LPVOID

.NET = IntPtr

C++ = typedef void *LPVOID;

LPWORD

.NET = IntPtr or ushort

C++ = typedef WORD *LPWORD;

LPWSTR

.NET = string or IntPtr or StringBuilder

C++ = typedef WCHAR *LPWSTR;

LRESULT

.NET = IntPtr or int

C++ = typedef LONG_PTR LRESULT;

PBOOL

.NET = IntPtr or bool

C++ = typedef BOOL *PBOOL;

PBOOLEAN

.NET = IntPtr or bool

C++ = typedef BOOLEAN *PBOOLEAN;

PBYTE

.NET = IntPtr or byte

C++ = typedef BYTE *PBYTE;

PCHAR

.NET = IntPtr or char

C++ = typedef CHAR *PCHAR;

PCSTR

.NET = string or IntPtr or StringBuilder

C++ = typedef CONST CHAR *PCSTR;

PCTSTR

.NET = string or IntPtr or StringBuilder

#ifdef UNICODE

C++ = typedef LPCWSTR PCTSTR;

#else

C++ = typedef LPCSTR PCTSTR;

PCWSTR

.NET = string or IntPtr or StringBuilder

C++ = typedef CONST WCHAR *PCWSTR;

PDWORD

.NET = IntPtr or uint

C++ = typedef DWORD *PDWORD;

PDWORDLONG

.NET = IntPtr or ulong

C++ = typedef DWORDLONG *PDWORDLONG;

PDWORD_PTR

.NET = IntPtr or uint

C++ = typedef DWORD_PTR *PDWORD_PTR;

PDWORD32

.NET = IntPtr or uint

C++ = typedef DWORD32 *PDWORD32;

PDWORD64

.NET = IntPtr or ulong

C++ = typedef DWORD64 *PDWORD64;

PFLOAT

.NET = IntPtr or single

C++ = typedef FLOAT *PFLOAT;

PHANDLE

.NET = IntPtr

C++ = typedef HANDLE *PHANDLE;

PHKEY

.NET = IntPtr

C++ = typedef HKEY *PHKEY;

PINT

.NET = IntPtr or int

C++ = typedef int *PINT;

PINT_PTR

.NET = IntPtr

C++ = typedef INT_PTR *PINT_PTR;

PINT32

.NET = IntPtr or int

C++ = typedef INT32 *PINT32;

PINT64

.NET = IntPtr or long

C++ = typedef INT64 *PINT64;

PLCID

.NET = IntPtr or uint

C++ = typedef PDWORD PLCID;

PLONG

.NET = IntPtr or int

C++ = typedef LONG *PLONG;

PLONGLONG

.NET = IntPtr or long

C++ = typedef LONGLONG *PLONGLONG;

PLONG_PTR

.NET = IntPtr or int

C++ = typedef LONG_PTR *PLONG_PTR;

PLONG32

.NET = IntPtr or int

C++ = typedef LONG32 *PLONG32;

PLONG64

.NET = IntPtr or long

C++ = typedef LONG64 *PLONG64;

POINTER_32

.NET = IntPtr or int

#if defined(_WIN64)

#define POINTER_32 __ptr32

#else

#define POINTER32

POINTER_64

.NET = IntPtr or long

#define POINTER_64 __ptr64

PSHORT

.NET = IntPtr or short

C++ = typedef SHORT *PSHORT;

PSIZE_T

.NET = IntPtr

C++ = typedef SIZE_T *PSIZE_T;

PSSIZE_T

.NET = IntPtr

C++ = typedef SSIZE_T *PSSIZE_T;

PSTR

.NET = IntPtr or string or StringBuilder

C++ = typedef CHAR *PSTR;

PTBYTE

.NET = IntPtr or char

C++ = typedef TBYTE *PTBYTE;

PTCHAR

.NET = IntPtr or string or StringBuilder

C++ = typedef TCHAR *PTCHAR;

PTSTR

.NET = IntPtr or string or StringBuilder

#ifdef UNICODE

C++ = typedef LPWSTR PTSTR;

#else

C++ = typedef LPSTR PTSTR;

PUCHAR

.NET = IntPtr or string or StringBuilder

C++ = typedef UCHAR *PUCHAR;

PUINT

.NET = IntPtr or uint

C++ = typedef UINT *PUINT;

PUINT_PTR

.NET = IntPtr or uint

C++ = typedef UINT_PTR *PUINT_PTR;

PUINT32

.NET = IntPtr or uint

C++ = typedef UINT32 *PUINT32;

PUINT64

.NET = IntPtr or ulong

C++ = typedef UINT64 *PUINT64;

PULONG

.NET = IntPtr or uint

C++ = typedef ULONG *PULONG;

PULONGLONG

.NET = IntPtr or ulong

C++ = typedef ULONGLONG *PULONGLONG;

PULONG_PTR

.NET = IntPtr or uint:

C++ = typedef ULONG_PTR *PULONG_PTR;

PULONG32

.NET = IntPtr or uint

C++ = typedef ULONG32 *PULONG32;

PULONG64

.NET = IntPtr or ulong

C++ = typedef ULONG64 *PULONG64;

PUSHORT

.NET = IntPtr or ushort

C++ = typedef USHORT *PUSHORT;

PVOID

.NET = IntPtr

C++ = typedef void *PVOID;

PWCHAR

.NET = IntPtr or string:

C++ = typedef WCHAR *PWCHAR;

PWORD

.NET = IntPtr or ushort

C++ = typedef WORD *PWORD;

PWSTR

.NET = IntPtr or string or StringBuilder

C++ = typedef WCHAR *PWSTR;

SC_HANDLE

.NET = IntPtr

C++ = typedef HANDLE SC_HANDLE;

SC_LOCK

.NET = IntPtr

C++ = typedef LPVOID SC_LOCK;

SERVICE_STATUS_HANDLE

.NET = IntPtr

C++ = typedef HANDLE SERVICE_STATUS_HANDLE;

SHORT

.NET = short

C++ = typedef short SHORT;

SIZE_T

.NET = uint or IntPtr

C++ = typedef ULONG_PTR SIZE_T;

SSIZE_T

.NET = int or IntPtr

C++ = typedef LONG_PTR SSIZE_T;

TBYTE

.NET = char

#ifdef UNICODE

C++ = typedef WCHAR TBYTE;

#else

C++ = typedef unsigned char TBYTE;

TCHAR

.NET = char

#ifdef UNICODE

C++ = typedef WCHAR TCHAR;

#else

C++ = typedef char TCHAR;

UCHAR

.NET = char

C++ = typedef unsigned char UCHAR;

UINT

.NET = uint:

C++ = typedef unsigned int UINT;

UINT_PTR

.NET = UIntPtr or uint:

#if defined(_WIN64)

C++ = typedef unsigned __int64 UINT_PTR;

#else

C++ = typedef unsigned int UINT_PTR;

UINT32

.NET = uint

C++ = typedef unsigned int

UINT32;

UINT64

.NET = ulong

C++ = typedef usigned __int

64 UINT64;

ULONG

.NET = uint:

C++ = typedef unsigned long ULONG;

ULONGLONG

.NET = ulong:

#if !defined(_M_IX86)

C++ = typedef unsigned __int64 ULONGLONG;

#else

C++ = typedef double ULONGLONG

ULONG_PTR

.NET = IntPtr or uint

#if defined(_WIN64)

C++ = typedef unsigned __int64 ULONG_PTR;

#else

C++ = typedef unsigned long ULONG_PTR;

ULONG32

.NET = uint

C++ = typedef unsigned int ULONG32;

ULONG64

.NET = ulong

C++ = typedef unsigned __int64 ULONG64;

USHORT

.NET = ushort

C++ = typedef unsigned short USHORT;

USN

.NET = long

C++ = typedef LONGLONG USN;

VOID

.NET = void:

#define VOID void

WCHAR

.NET = char

C++ = typedef wchar_t WCHAR;

WINAPI

.NET = standard is default, look at the CallingConvention enumeration:

#define WINAPI __stdcall

WORD

.NET = ushort

C++ = typedef unsigned short WORD;

WPARAM

.NET = IntPtr or uint:

C++ = typedef UINT_PTR WPARAM;

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
AnswerRe: How to pass IntPtr to COM (Help, urgent) Pin
kbrryder5-Jul-06 11:33
kbrryder5-Jul-06 11:33 
GeneralHelp!Please! Pin
anders ling12-Jun-06 19:39
anders ling12-Jun-06 19:39 
AnswerRe: Help!Please! Pin
kbrryder13-Jun-06 7:21
kbrryder13-Jun-06 7:21 
GeneralRe: Help!Please! Pin
brian.hawley29-Jul-06 2:09
brian.hawley29-Jul-06 2:09 
GeneralShall we chat on MSN? Pin
anders ling29-Jul-06 2:18
anders ling29-Jul-06 2:18 
GeneralRe: Shall we chat on MSN? Pin
brian.hawley29-Jul-06 2:24
brian.hawley29-Jul-06 2:24 
GeneralExcellent Pin
Snews4-Jun-06 4:07
Snews4-Jun-06 4:07 
Questionhow to call it in vb.net Pin
xiaowen0110-May-06 22:18
xiaowen0110-May-06 22:18 
this is in vc++,it can work right

typedef struct
{
struct
{
CHAR szFilename[ _MAX_FNAME];
CHAR szRevision[ 32];
}
upperDll;

struct
{
CHAR szFilename[ _MAX_FNAME];
CHAR szRevision[ 32];
}
lowerDll;
}
DLL_INFORMATION, *LPDLL_INFORMATION;



/* Data structure for command message */
typedef struct
{
BYTE bCommandCode;
BYTE bParameterCode;

struct
{
DWORD dwSize;
LPBYTE lpbBody;
}
Data;
}
COMMAND, *LPCOMMAND;



/* Received message type */
typedef enum
{
PositiveReply,
NegativeReply,
ReplyReceivingFailure,
CommandCancellation,
ReplyTimeout,
}
REPLY_TYPE, *LPREPLY_TYPE;



/* Data structure for positive reply message */
typedef struct
{
BYTE bCommandCode;
BYTE bParameterCode;

struct
{
BYTE bSt1;
BYTE bSt0;
}
StatusCode;

struct
{
DWORD dwSize;
BYTE bBody[ MAX_DATA_ARRAY_SIZE];
}
Data;
}
POSITIVE_REPLY, *LPPOSITIVE_REPLY;



/* Data structure for negative reply message */
typedef struct
{
BYTE bCommandCode;
BYTE bParameterCode;

struct
{
BYTE bE1;
BYTE bE0;
}
ErrorCode;

struct
{
DWORD dwSize;
BYTE bBody[ MAX_DATA_ARRAY_SIZE];
}
Data;
}
NEGATIVE_REPLY, *LPNEGATIVE_REPLY;



/* Data structure for reply message */
typedef struct
{
REPLY_TYPE replyType;

union
{
POSITIVE_REPLY positiveReply;
NEGATIVE_REPLY negativeReply;
}
message;

}
REPLY, *LPREPLY;



/*
--------------------------------------------------------------------------------------------------
Return codes of the APIs
*/

#define _ERROR_CODE_ORIGIN (0x0000)


/*
Return codes of the following API(s):
- GetDllInformation
- ConnectDevice
- DisconnectDevice
- ExecuteCommand
- CancelCommand
*/
#define _NO_ERROR ( _ERROR_CODE_ORIGIN + 0x0 )
#define _DEVICE_NOT_CONNECTED_ERROR ( _ERROR_CODE_ORIGIN + 0x1 )
#define _CANCEL_COMMAND_SESSION_ERROR ( _ERROR_CODE_ORIGIN + 0x2 )
#define _FAILED_TO_SEND_COMMAND_ERROR ( _ERROR_CODE_ORIGIN + 0x3 )
#define _FAILED_TO_RECEIVE_REPLY_ERROR ( _ERROR_CODE_ORIGIN + 0x4 )
#define _COMMAND_CANCELED ( _ERROR_CODE_ORIGIN + 0x5 )
#define _REPLY_TIMEOUT ( _ERROR_CODE_ORIGIN + 0x6 )



/*
Return codes of the following API(s):
- GetDllInformation

nothing unique ErrorCode
*/

/*
Return codes of the following API(s):
- ConnectDevice
*/
#define _CANNOT_CREATE_OBJECT_ERROR ( _ERROR_CODE_ORIGIN + 0x0101 )
#define _DEVICE_NOT_READY_ERROR ( _ERROR_CODE_ORIGIN + 0x0102 )
#define _CANNOT_OPEN_PORT_ERROR ( _ERROR_CODE_ORIGIN + 0x0103 )
#define _FAILED_TO_BEGIN_THREAD_ERROR ( _ERROR_CODE_ORIGIN + 0x0104 )
#define _DEVICE_ALREADY_CONNECTED_ERROR ( _ERROR_CODE_ORIGIN + 0x0105 )


/*
Return codes of the following API(s):
- DisconnectDevice

nothing unique ErrorCode
*/

/*
Return codes of the following API(s):
- CancelCommand

nothing unique ErrorCode
*/

/*
Return codes of the following API(s):
- UpdateFirmware
*/
#define _UPDATE_FIRMWARE_UNEXPECTED_ERROR ( _ERROR_CODE_ORIGIN + 0x1001 )
#define _UPDATE_FIRMWARE_UNKNOWN_FILE_TYPE_ERROR ( _ERROR_CODE_ORIGIN + 0x1002 )
#define _UPDATE_FIRMWARE_CANNOT_OPEN_FILE_ERROR ( _ERROR_CODE_ORIGIN + 0x1003 )
#define _UPDATE_FIRMWARE_FAILED_TO_ALLOCATE_MEMORY_REGION_ERROR ( _ERROR_CODE_ORIGIN + 0x1004 )
#define _UPDATE_FIRMWARE_CANNOT_READ_FILE_ERROR ( _ERROR_CODE_ORIGIN + 0x1005 )
#define _UPDATE_FIRMWARE_CONNECT_DEVICE_FAILED_ERROR ( _ERROR_CODE_ORIGIN + 0x1006 )
#define _UPDATE_FIRMWARE_DEVICE_ALREADY_CONNECTED_ERROR ( _ERROR_CODE_ORIGIN + 0x1007 )
#define _UPDATE_FIRMWARE_COMMAND_EXECUTION_FAILED_ERROR ( _ERROR_CODE_ORIGIN + 0x1008 )
#define _UPDATE_FIRMWARE_NEGATIVE_REPLY_RECEIVED_ERROR ( _ERROR_CODE_ORIGIN + 0x1009 )
#define _UPDATE_FIRMWARE_DISCONNECT_DEVICE_FAILED_ERROR ( _ERROR_CODE_ORIGIN + 0x100A )
#define _UPDATE_FIRMWARE_UNEXPECTED_FILE_CONTENTS_ERROR ( _ERROR_CODE_ORIGIN + 0x100B )
#define _UPDATE_FIRMWARE_IDENTICAL_REVISION_ERROR ( _ERROR_CODE_ORIGIN + 0x100C )


/*
Return codes of the following API(s):
- ICCardTransmit
*/
#define _ICC_TRANSMIT_UNEXPECTED_ERROR ( _ERROR_CODE_ORIGIN + 0x2001 )
#define _ICC_TRANSMIT_FAILED_TO_ALLOCATE_MEMORY_REGION_ERROR ( _ERROR_CODE_ORIGIN + 0x2002 )
#define _ICC_TRANSMIT_ABORT_REQUEST_RECEIVED_ERROR ( _ERROR_CODE_ORIGIN + 0x2003 )
#define _ICC_TRANSMIT_COMMAND_EXECUTION_FAILED_ERROR ( _ERROR_CODE_ORIGIN + 0x2004 )
#define _ICC_TRANSMIT_NEGATIVE_REPLY_RECEIVED_ERROR ( _ERROR_CODE_ORIGIN + 0x2005 )


/*
Return codes of the following API(s):
- SAMTransmit
*/
#define _SAM_TRANSMIT_UNEXPECTED_ERROR ( _ERROR_CODE_ORIGIN + 0x3001 )
#define _SAM_TRANSMIT_FAILED_TO_ALLOCATE_MEMORY_REGION_ERROR ( _ERROR_CODE_ORIGIN + 0x3002 )
#define _SAM_TRANSMIT_ABORT_REQUEST_RECEIVED_ERROR ( _ERROR_CODE_ORIGIN + 0x3003 )
#define _SAM_TRANSMIT_COMMAND_EXECUTION_FAILED_ERROR ( _ERROR_CODE_ORIGIN + 0x3004 )
#define _SAM_TRANSMIT_NEGATIVE_REPLY_RECEIVED_ERROR ( _ERROR_CODE_ORIGIN + 0x3005 )



/*
The end of the declaration of return codes for the APIs
--------------------------------------------------------------------------------------------------
*/

typedef VOID ( WINAPI *CALL_BACK_FUNCTION) ( WPARAM, LPARAM);


#ifndef _DLL_DEVELOPMENT_
#define DLL_API __declspec( dllimport)
#else
#define DLL_API __declspec( dllexport)
#endif

DLL_API DWORD WINAPI ExecuteCommand( LPCSTR, CONST COMMAND, CONST DWORD,

#endif /* _ICT3K5_6240DLL_H_ */


but I should work in vb.net,how can call this dll in vb.net,thanks!


thanks!

AnswerRe: how to call it in vb.net Pin
kbrryder11-May-06 7:46
kbrryder11-May-06 7:46 
GeneralProblem with C++ functions returning bool Pin
SolidPig3-May-06 1:07
SolidPig3-May-06 1:07 
GeneralRe: Problem with C++ functions returning bool Pin
kbrryder3-May-06 7:27
kbrryder3-May-06 7:27 
GeneralRe: Problem with C++ functions returning bool Pin
SolidPig3-May-06 23:00
SolidPig3-May-06 23:00 
GeneralRe: Problem with C++ functions returning bool Pin
tl77777776-Aug-06 10:55
tl77777776-Aug-06 10:55 
QuestionMethod signature problem [Urgent reply required] Pin
t4ure4n16-Apr-06 9:00
t4ure4n16-Apr-06 9:00 
AnswerRe: Method signature problem [Urgent reply required] Pin
kbrryder17-Apr-06 6:35
kbrryder17-Apr-06 6:35 
AnswerRe: Method signature problem [Urgent reply required] Pin
t4ure4n17-Apr-06 9:34
t4ure4n17-Apr-06 9:34 
QuestionRe: Method signature problem [Urgent reply required] Pin
t4ure4n26-Apr-06 4:31
t4ure4n26-Apr-06 4:31 
AnswerRe: Method signature problem [Urgent reply required] Pin
kbrryder26-Apr-06 7:23
kbrryder26-Apr-06 7:23 
GeneralIntPtr to HANDLE URGENT Pin
k0l0s026-Oct-05 1:26
k0l0s026-Oct-05 1:26 
GeneralRe: IntPtr to HANDLE URGENT Pin
kbrryder26-Oct-05 5:28
kbrryder26-Oct-05 5:28 
GeneralRe: IntPtr to HANDLE URGENT Pin
k0l0s026-Oct-05 7:41
k0l0s026-Oct-05 7:41 
GeneralRe: IntPtr to HANDLE URGENT Pin
kbrryder26-Oct-05 8:04
kbrryder26-Oct-05 8:04 
Generalwonderful article Pin
g gm1-Oct-05 17:30
g gm1-Oct-05 17:30 
GeneralPrinter settings done thru WinAPIs does't reflect into the driver Pin
nvkar27-Jun-05 6:30
nvkar27-Jun-05 6:30 
GeneralRe: Printer settings done thru WinAPIs does't reflect into the driver Pin
kbrryder28-Jun-05 5:33
kbrryder28-Jun-05 5:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.