Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/146.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在C+;中为USB投影仪使用DLL接口+;_C++_Dll - Fatal编程技术网

C++ 如何在C+;中为USB投影仪使用DLL接口+;

C++ 如何在C+;中为USB投影仪使用DLL接口+;,c++,dll,C++,Dll,我有一个叫做DLP Discovery 4000的硬件。它用于图像的投影。用户可以对其进行编程。在硬件编程指南中,它有一个可以在DLL API接口中访问的函数列表。指南说这些函数可以通过C++/C/Java调用 我希望能够使用C++程序中的这些函数来控制板。但到目前为止,我正在为如何使用DLL API而苦苦挣扎 它附带了一个我安装的软件。该软件的GUI功能有限。此外,软件将名为D4000_usb.dll的文件放入windows目录中。如何使用此.dll文件。我发现有人在 我已经在它前面添加了一些

我有一个叫做DLP Discovery 4000的硬件。它用于图像的投影。用户可以对其进行编程。在硬件编程指南中,它有一个可以在DLL API接口中访问的函数列表。指南说这些函数可以通过C++/C/Java调用

<>我希望能够使用C++程序中的这些函数来控制板。但到目前为止,我正在为如何使用DLL API而苦苦挣扎


它附带了一个我安装的软件。该软件的GUI功能有限。此外,软件将名为D4000_usb.dll的文件放入windows目录中。如何使用此.dll文件。

我发现有人在

我已经在它前面添加了一些助手注释
/***
,为您提供一些指导

#include <windows.h> 
#include <stdio.h> 
#include <iostream>

typedef int (__cdecl *MYPROC)(LPWSTR); 

int main( void ) 
{ 

    HINSTANCE hinstLib; 
    MYPROC ProcAdd; 
    BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; 

    // *** This loads the API DLL into you program

    // Get a handle to the DLL module.
    hinstLib = LoadLibrary(TEXT("D4000_usb.dll")); 


    // *** Now we check if it loaded ok - ie we should have a handle to it

    // If the handle is valid, try to get the function address.
    if (hinstLib != NULL) 
    { 

        // *** Now we try and get a handle to the function GetNumDev

        ProcAdd = (MYPROC) GetProcAddress(hinstLib, "GetNumDev"); 

       // *** Now we check if it that worked

        // If the function address is valid, call the function.
        if (NULL != ProcAdd) 
        {
            fRunTimeLinkSuccess = TRUE;

            // *** Now we call the function with a string parameter

            (ProcAdd) (L"Message sent to the DLL function\n"); 


            // *** this is where you need to check if the function call worked
            // *** and this where you need to read the manual to see what it returns

        }


       // *** Now we unload the API dll

        // Free the DLL module.
        fFreeResult = FreeLibrary(hinstLib); 
    } 

    // *** Here is a message to check if the the previous bit worked


    // If unable to call the DLL function, use an alternative.
    if (! fRunTimeLinkSuccess) 
        printf("Message printed from executable\n"); 

return 0;
}
#包括
#包括
#包括
typedef int(uu cdecl*MYPROC)(LPWSTR);
内部主(空)
{ 
HINSTANCE hinstLib;
MYPROC-ProcAdd;
BOOL fFreeResult,fRunTimeLinkSuccess=FALSE;
//***这会将API DLL加载到您的程序中
//获取DLL模块的句柄。
hinstLib=LoadLibrary(文本(“D4000_usb.dll”);
//***现在我们检查它是否加载正常-即我们应该有一个句柄
//如果句柄有效,请尝试获取函数地址。
if(hinstLib!=NULL)
{ 
//***现在我们尝试获取函数GetNumDev的句柄
ProcAdd=(MYPROC)GetProcAddress(hinstLib,“GetNumDev”);
//***现在我们检查它是否有效
//如果函数地址有效,则调用函数。
如果(NULL!=ProcAdd)
{
fRunTimeLinkSuccess=TRUE;
//***现在我们使用字符串参数调用函数
(ProcAdd)(L“发送到DLL函数的消息\n”);
//***这是您需要检查函数调用是否有效的地方
//***在这里,您需要阅读手册以查看它返回的内容
}
//***现在我们卸载API dll
//释放DLL模块。
fFreeResult=自由库(hinstLib);
} 
//***以下是一条消息,用于检查前一位是否工作
//如果无法调用DLL函数,请使用其他方法。
如果(!fRunTimeLinkSuccess)
printf(“从可执行文件打印的消息”);
返回0;
}

请查看手册,手册中是否给出了可调用函数的定义。上面有没有提到declspec?或者它提到了LoadLibrary,或者一个.DEF文件?如果有,请告诉我们。手册中有任何示例程序吗?