请问如何调用.dll文件中的类
bs
|
1#
bs 发表于 2007-01-16 18:08
请问如何调用.dll文件中的类
[Copy to clipboard] [ - ]
CODE:
00105 class CSgip;
00106 00110 class CJobSgip : public IJobDesc { 00111 public: 00112 CJobSgip(SOCKET &hSocket, CSgip* sgip, unsigned remoteport); 00113 CJobSgip(sgipg_submit pss, CSgip* sgip, unsigned int nSeq, unsigned int nDateTime); 00114 ~CJobSgip(); 00115 00116 void RecvMOProc(); 00117 void SendMTProc(); 00118 int nType; 00119 00120 private: 00121 sgip_conn sp_conn; 00122 CSgip* m_sgip; 00123 sgipg_submit ss; 00124 unsigned m_nSeq; 00125 unsigned m_nDateTime; 00126 }; 00127 00131 class CWorkerSgip : public IWorker { 00132 virtual void ProcessJob( IJobDesc* pJobDesc ); 00133 }; 00134 00138 class ConnInfo { 00139 public: 00140 ConnInfo() { 00141 socketHandle = 0; 00142 port = 0; 00143 connectedTime = _T(""); 00144 } 00145 00146 ConnInfo( 00147 unsigned _socketHandle, 00148 unsigned _port, 00149 CString _connectedTime 00150 ) { 00151 socketHandle = _socketHandle; 00152 port = _port; 00153 connectedTime = _connectedTime; 00154 } 00155 00156 unsigned socketHandle; 00157 unsigned port; 00158 CString connectedTime; 00159 }; 00160 00161 typedef std::list<ConnInfo> cList; 00162 00166 class SGIP_API CSgip{ 00167 friend class CJobSgip; 00168 public: 00169 00173 CSgip(); 00174 00178 ~CSgip(); 00179 00215 int Start( 00216 char *sLocalIP, 00217 int nLocalPort, 00218 char *sPeerIP, 00219 int nPeerPort, 00220 char *sLoginName, 00221 char *sLoginPwd, 00222 int nConnType, 00223 char *sSrcNum, 00224 int (*OnDeliver)(DeliverStr deliver), 00225 int (*OnReport)(ReportStr report), 00226 int (*OnResponse)(MTRespStr response), 00227 int (*OnMTError)(MTErrorStr mterror), 00228 int nConnCount = 3, 00229 bool fOutputDebugInfo = false, 00230 char *sPeerName = NULL, 00231 char *sPeerPwd = NULL, 00232 unsigned nMaxSmgConn = 16, 00233 unsigned nMinWorkThreadsCount = 4, 00234 unsigned nMaxWorkThreadsCount = 8, 00235 int (*OnLogWrite)(const char* pchFmt, ...) = NULL 00236 ); 00237 00241 void Release( 00242 BOOL forceRelease = FALSE 00243 ); 00244 00250 void Submit( 00251 sgipg_submit ss, 00252 unsigned &nSeq, 00253 unsigned &nDateTime 00254 ); 00255 00262 int AddUserNumber( 00263 sgipg_submit* ss, 00264 const char* sUserNumber 00265 ); 00266 00270 unsigned int GetSubmitSeqId(); 00271 00275 void GetSmgConnInfo( 00276 cList & _connList 00277 ) { 00278 _connList = connList; 00279 return; 00280 } 00281 00284 // 00285 unsigned GetSmgConnCount() { return (unsigned)connList.size(); } 00286 00287 protected: 00288 int SubmitFunc(sgipg_submit ss, unsigned int nSeq, unsigned int nDateTime); 00289 00290 private: 00291 bool LocalListen(); 00292 bool IsValidIPAddr(LPCTSTR sIPAddr); 00293 bool CreateLogFile(); 00294 sgip_conn* GetSubmitConn(int &nConnIndex); 00295 void ChangeStatus(int nConnIndex, bool fBusy); 00296 int LoginSmg(sgip_conn *pConn); 00297 void LogoutSmg(sgip_conn *pConn); 00298 bool CreateConn(); 00299 bool ReleaseConn(); 00300 void AddSmgConn(unsigned socketHandle, unsigned port); 00301 void RemoveSmgConn(unsigned socketHandle); 00302 CString GetDateTime(); 00303 unsigned GetMaxSmgConnections() { return m_nMaxSmgConn; } 00304 00305 private: 00306 static DWORD WINAPI SgipServFunc(LPVOID pParam); 00307 virtual DWORD SgipServProc(); 00308 int (*m_PDeliver)(DeliverStr deliver); 00309 int (*m_PReport)(ReportStr report); 00310 int (*m_PResponse)(MTRespStr response); 00315 int (*m_PMTError)(MTErrorStr mterror); 00316 int (*m_LogWrite)(const char* pchFmt, ...); 00317 CString GetPeerName() { return m_sPeerName; } 00318 CString GetPeerPwd() { return m_sPeerPwd; } 00319 00320 private: 00321 CString m_sPeerAddr; 00322 int m_nPeerPort; 00323 CString m_sUserName; 00324 CString m_sPwd; 00325 int m_nConnType; 00326 int m_nSubmitConn; 00327 CString m_sSrcNum; 00328 CString m_sLocalIPAddr; 00329 int m_nLocalPort; 00330 CString m_sPeerName; 00331 CString m_sPeerPwd; 00332 unsigned m_nMaxSmgConn; 00333 00334 CString m_sLogPath; 00335 BOOL m_fLogEvent; 00336 00337 CThreadPool pool; 00338 CWorkerSgip m_worker; 00339 CJobSgip *m_pJob; 00340 unsigned m_nMinWorkThreadsCount; 00341 unsigned m_nMaxWorkThreadsCount; 00342 00343 BOOL m_fStarted; 00344 BOOL m_fStop; 00345 00346 SOCKET serverSocket; 00347 HANDLE m_hThread; 00348 00349 unsigned m_nCounter; 00350 00351 sgip_conn SubmitConn[MAX_PATH]; 00352 CCriticalSection m_arrayCs; 00353 int m_nConnIndex; 00354 CCriticalSection m_listCs; 00355 cList connList; 00356 }; 用python开发联通的短信网关SGIP.DLL封装库 我的做法如下: from ctypes import * mydll=windll.LoadLibrary("examples\SGIP.dll") 结果如下: >>> mygip=mydll.CSgip() AttributeError: function 'CSgip' not found >>> mygip=mydll.CSgip.CSgip() AttributeError: function 'CSgip' not found |