- 论坛徽章:
- 0
|
------**求教各路大神!!!**------
Python调用用C++写的dll,这个dll有调用另一个dll,设为B.dll,这个B.dll中封装了
C#,结果在运行python时出现错误:
【OSError: [WinError -532462766] Windows Error 0x%X】
python代码如下:- import ctypes, os
- from ctypes import *
- CUR_PATH = os.path.dirname(__file__)
- devGenDll = ctypes.WinDLL(os.path.join(CUR_PATH, "RF_MES.dll"))
- devGenDll.InitWS(ctypes.c_char_p(b'www.xxxx.nett'))
- deviceID = devGenDll.GetDeviceID("11", "7")
- print(deviceID)
复制代码 RF_MES.dll中主要代码如下:- #include "stdafx.h"
- #include "WSDataTransCpp.h"
- #include <stdlib.h>
- #include <stdio.h>
- #define SUCCESS 1
- extern "C"{
- CWSDataTransCpp* wsDataTrans;
- __declspec(dllexport) void __stdcall InitWS(char* serverIP)
- {
- printf("InitWS");
- wsDataTrans = new CWSDataTransCpp(serverIP);
-
- }
- __declspec(dllexport) char* __stdcall GetDeviceID(char* lineNo, char* stationNo)
- {
- if(wsDataTrans && wsDataTrans->ConnectCheck())
- return wsDataTrans->ObtainDeviceID(lineNo, stationNo);
- //printf("GetDeviceID");
- return NULL;
- }
- __declspec(dllexport) int __stdcall UploadResult(char* lineNo, char* stationNo, char* deviceID, char* result)
- {
- return SUCCESS;
- }
- }
复制代码 |
|