将一个字符串参数从VFP 9发送到在c++Visual Studio上创建的dll

Send a String parameter from VFP 9 to a dll created on c++ Visual Studio

本文关键字:c++Visual Studio dll 创建 9发 VFP 一个 参数 字符串      更新时间:2023-10-16

我在C++Visual Studio中使用OpenCV创建了一个DLL来捕捉相机的图像。我收到参数字符串。

通常在发送时,我得到的是"Declare DLL call caused a exception",我不确定问题是我在VFP上发送的变量类型还是我在C++上接收的变量类型。

DLL

extern "C" 
    {     
        __declspec(dllexport) void CamPhoto(int,String);
    }

extern void __cdecl CamPhoto(int cam, string name)  
{  
    char aux[100];
    strcpy(aux, name.c_str());
    CvCapture *capture = 0;
    capture= cvCreateCameraCapture(cam);
    IplImage *frame=0;
    //SaveImage
    char FileName[100];
    char auxpath[100];
    for(int i=0; i<2; i++){
        frame = cvQueryFrame(capture);
        sprintf(FileName,"/%s.jpg",aux);
        strcpy(auxpath,"C:/Users/Emi/Pictures");
        strcat(auxpath,FileName);
        cvSaveImage(auxpath,frame);
    }
    cvReleaseCapture(&capture);
    delete [] aux;
}

VFP

DECLARE CamPhotoIn "CamCapture.dll" INTEGER, STRING
CamPhoto(0, "TestVFP")

尝试更改为…这样就可以强制将指针传递给字符串,而不是字符串本身。它可能会帮你度过难关。

DECLARE CamPhotoIn "CamCapture.dll" INTEGER, @STRING
testString = "TestVFP"
CamPhoto(0, @testString )