这个是Dll的 .h文件://-----------------------------------------------------------------------
// Copyright (c) 2006 Wireless Studio. All Rights Reserved.
//
// This software is the confidential and proprietary
// information of Wireless Studio. ("Confidential Information").
// You shall not disclose such Confidential Information
// and shall use it only in accordance with the terms of
// the license agreement you entered into with Wireless Studio.
//
// Author:
//-----------------------------------------------------------------------#ifdef SOMPAPI_EXPORTS
#define SOMPAPI_API __declspec(dllexport)
#else
#define SOMPAPI_API __declspec(dllimport)
#endif/////////////////////////////////////////////////////////////////////////
// SMSMOREQ structure
typedef struct tagSMSMOREQ
{
char szDestAddr[32];
void * lpContent;
UINT nBytesOfContent;
UINT nDataCoding;
UINT nProtocolID;
UINT nEsmClass;
unsigned __int64 nMessageID;
char szSourceAddr[32];
char szShortCode[32];
char szModule[32];
} SMSMOREQ;/////////////////////////////////////////////////////////////////////////
// SMSMTACK structure
typedef struct tagSMSMTACK
{
unsigned __int64 nMessageID;
int nResult;
} SMSMTACK;/////////////////////////////////////////////////////////////////////////
// SMSDRREQ structure
typedef struct tagSMSDRREQ
{
unsigned __int64 nMessageID;
int nReceipt;
unsigned __int64 nCatalogue;
char szSourceAddr[32];
char szStat[32];
} SMSDRREQ;/////////////////////////////////////////////////////////////////////////
// SMSMTREQ structure
typedef struct tagSMSMTREQ
{
unsigned __int64 nCatalogue;
char szSourceAddr[32];
char szModule[32];
UINT nBytesOfContent;
void * lpContent;
UINT nDataCoding;
UINT nProtocolID;
UINT nRegisteredDelivery;
UINT nEsmClass;
UINT nRetry;
UINT nBytesOfDestAddr;
char * lpszDestAddr;
} SMSMTREQ;/////////////////////////////////////////////////////////////////////////
// ACTION define
#define ACTION_SMSMTREQ 0x04
#define ACTION_SMSMTACK 0x84#define ACTION_SMSMOREQ 0x05
#define ACTION_SMSMOACK 0x85#define ACTION_SMSDRREQ 0x08
#define ACTION_SMSDRACK 0x88#define ACTION_SMSMTACKTIMEOUT 0x10084#define ACTION_SHUTDOWN 0x10001
#define ACTION_SOCKETCLOSE 0x10002#define ACTION_BINDREQ 0x01
#define ACTION_BINDACK 0x81#define ACTION_TX_HEARTBEATREQ 0x102
#define ACTION_RX_HEARTBEATREQ 0x202
#define ACTION_RX_HEARTBEATACK 0x182
#define ACTION_TX_HEARTBEATACK 0x282#define ACTION_TX_TERMREQ 0x10E
#define ACTION_RX_TERMACK 0x18E
#define ACTION_RX_TERMREQ 0x20E
#define ACTION_TX_TERMACK 0x28E#define ACTION_TX_HALT 0x1EE
#define ACTION_RX_HALT 0x2EE#define ACTION_UNKNOWN 0xFFFFF/////////////////////////////////////////////////////////////////////////
// Callback function
typedef DWORD (WINAPI * pfSmsEventListener)(int nAction, void * pReq, void * pAck);////////////////////////////////////////////////////////////////////////////
// Function define
SOMPAPI_API HANDLE WINAPI SompCreateContext();
SOMPAPI_API void WINAPI SompReleaseContext(HANDLE handle);SOMPAPI_API void WINAPI SompSetHost(HANDLE handle, LPCSTR lpszAddress, UINT nPort,
DWORD dwSocketTimeout, DWORD dwLinkTimeout);
SOMPAPI_API void WINAPI SompSetListener(HANDLE handle, pfSmsEventListener pf);
SOMPAPI_API BOOL WINAPI SompSetCredence(HANDLE handle, LPCSTR lpszUsername, LPCSTR lpszPassword);SOMPAPI_API BOOL WINAPI SompStart(HANDLE handle);
SOMPAPI_API void WINAPI SompStop(HANDLE handle);SOMPAPI_API BOOL WINAPI SompSend(HANDLE handle, SMSMTREQ * pReq, SMSMTACK * pAck, DWORD dwTimeout);针对这个Dll我写了一个类:
大致如下: [DllImport("SompApi.dll",CharSet = CharSet.Auto)]
public static extern IntPtr SompCreateContext();
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern void SompReleaseContext(IntPtr nHandle);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern void SompSetHost(IntPtr nHandle,[MarshalAs(UnmanagedType.LPTStr)]string szIpAdress,uint nPort,uint nSocketTimeOut,uint nLinkTimeOut);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern bool SompSetCredence(IntPtr nHandle,[MarshalAs(UnmanagedType.LPTStr)]string szUserName,[MarshalAs(UnmanagedType.LPTStr)]string szPassWord);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern ulong pfSmsEventListener(int nAction,StringBuilder strReq,StringBuilder strAck);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern bool SompSend(StringBuilder strReq,StringBuilder strAck,ulong lTimeOut);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern bool SompStart(IntPtr nHandle);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern void SompStop(IntPtr nHandle);当我调用第一个函数的时候提示我:Unable to find an entry point named 'SompCreateContext' in DLL 'SompApi.dll''
这个是怎么回事!?
// Copyright (c) 2006 Wireless Studio. All Rights Reserved.
//
// This software is the confidential and proprietary
// information of Wireless Studio. ("Confidential Information").
// You shall not disclose such Confidential Information
// and shall use it only in accordance with the terms of
// the license agreement you entered into with Wireless Studio.
//
// Author:
//-----------------------------------------------------------------------#ifdef SOMPAPI_EXPORTS
#define SOMPAPI_API __declspec(dllexport)
#else
#define SOMPAPI_API __declspec(dllimport)
#endif/////////////////////////////////////////////////////////////////////////
// SMSMOREQ structure
typedef struct tagSMSMOREQ
{
char szDestAddr[32];
void * lpContent;
UINT nBytesOfContent;
UINT nDataCoding;
UINT nProtocolID;
UINT nEsmClass;
unsigned __int64 nMessageID;
char szSourceAddr[32];
char szShortCode[32];
char szModule[32];
} SMSMOREQ;/////////////////////////////////////////////////////////////////////////
// SMSMTACK structure
typedef struct tagSMSMTACK
{
unsigned __int64 nMessageID;
int nResult;
} SMSMTACK;/////////////////////////////////////////////////////////////////////////
// SMSDRREQ structure
typedef struct tagSMSDRREQ
{
unsigned __int64 nMessageID;
int nReceipt;
unsigned __int64 nCatalogue;
char szSourceAddr[32];
char szStat[32];
} SMSDRREQ;/////////////////////////////////////////////////////////////////////////
// SMSMTREQ structure
typedef struct tagSMSMTREQ
{
unsigned __int64 nCatalogue;
char szSourceAddr[32];
char szModule[32];
UINT nBytesOfContent;
void * lpContent;
UINT nDataCoding;
UINT nProtocolID;
UINT nRegisteredDelivery;
UINT nEsmClass;
UINT nRetry;
UINT nBytesOfDestAddr;
char * lpszDestAddr;
} SMSMTREQ;/////////////////////////////////////////////////////////////////////////
// ACTION define
#define ACTION_SMSMTREQ 0x04
#define ACTION_SMSMTACK 0x84#define ACTION_SMSMOREQ 0x05
#define ACTION_SMSMOACK 0x85#define ACTION_SMSDRREQ 0x08
#define ACTION_SMSDRACK 0x88#define ACTION_SMSMTACKTIMEOUT 0x10084#define ACTION_SHUTDOWN 0x10001
#define ACTION_SOCKETCLOSE 0x10002#define ACTION_BINDREQ 0x01
#define ACTION_BINDACK 0x81#define ACTION_TX_HEARTBEATREQ 0x102
#define ACTION_RX_HEARTBEATREQ 0x202
#define ACTION_RX_HEARTBEATACK 0x182
#define ACTION_TX_HEARTBEATACK 0x282#define ACTION_TX_TERMREQ 0x10E
#define ACTION_RX_TERMACK 0x18E
#define ACTION_RX_TERMREQ 0x20E
#define ACTION_TX_TERMACK 0x28E#define ACTION_TX_HALT 0x1EE
#define ACTION_RX_HALT 0x2EE#define ACTION_UNKNOWN 0xFFFFF/////////////////////////////////////////////////////////////////////////
// Callback function
typedef DWORD (WINAPI * pfSmsEventListener)(int nAction, void * pReq, void * pAck);////////////////////////////////////////////////////////////////////////////
// Function define
SOMPAPI_API HANDLE WINAPI SompCreateContext();
SOMPAPI_API void WINAPI SompReleaseContext(HANDLE handle);SOMPAPI_API void WINAPI SompSetHost(HANDLE handle, LPCSTR lpszAddress, UINT nPort,
DWORD dwSocketTimeout, DWORD dwLinkTimeout);
SOMPAPI_API void WINAPI SompSetListener(HANDLE handle, pfSmsEventListener pf);
SOMPAPI_API BOOL WINAPI SompSetCredence(HANDLE handle, LPCSTR lpszUsername, LPCSTR lpszPassword);SOMPAPI_API BOOL WINAPI SompStart(HANDLE handle);
SOMPAPI_API void WINAPI SompStop(HANDLE handle);SOMPAPI_API BOOL WINAPI SompSend(HANDLE handle, SMSMTREQ * pReq, SMSMTACK * pAck, DWORD dwTimeout);针对这个Dll我写了一个类:
大致如下: [DllImport("SompApi.dll",CharSet = CharSet.Auto)]
public static extern IntPtr SompCreateContext();
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern void SompReleaseContext(IntPtr nHandle);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern void SompSetHost(IntPtr nHandle,[MarshalAs(UnmanagedType.LPTStr)]string szIpAdress,uint nPort,uint nSocketTimeOut,uint nLinkTimeOut);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern bool SompSetCredence(IntPtr nHandle,[MarshalAs(UnmanagedType.LPTStr)]string szUserName,[MarshalAs(UnmanagedType.LPTStr)]string szPassWord);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern ulong pfSmsEventListener(int nAction,StringBuilder strReq,StringBuilder strAck);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern bool SompSend(StringBuilder strReq,StringBuilder strAck,ulong lTimeOut);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern bool SompStart(IntPtr nHandle);
[DllImport("SompApi.dll", CharSet = CharSet.Auto)]
public static extern void SompStop(IntPtr nHandle);当我调用第一个函数的时候提示我:Unable to find an entry point named 'SompCreateContext' in DLL 'SompApi.dll''
这个是怎么回事!?
另外, 我在源代码中看到这个...
#ifdef SOMPAPI_EXPORTS
#define SOMPAPI_API __declspec(dllexport)
#else
#define SOMPAPI_API __declspec(dllimport)
#endif
晕啊, 是导入函数还是导出API啊.