代码如下:
在VC中:
extern "C" __declspec(dllexport) LONG APIENTRY CheckKey(HWND hwnd, LPLONG lpIValue, LPSTR lpszValue)
{
MessageBox(hwnd, "ok", "ok", MB_OK);
return 42;
}在InstallShield中:
szDLL = SUPPORTDIR ^ "InstDLL.DLL";
szFunction = "CheckKey";
nValue = 0;
szValue = "";
nRet = CallDLLFx(szDLL, szFunction, nValue, szValue); //nRet 总是返回 -1请问这是怎么回事呀?

解决方案 »

  1.   

    szDLL = SUPPORTDIR ^ "InstDLL.DLL";应该是这样
    szDLL = SUPPORTDIR ^ @"InstDLL.DLL";
    或者是
    szDLL = SUPPORTDIR @^ "InstDLL.DLL";
    具体我也几不清了
    你再试试啊
      

  2.   

    给你一个测试通过的:
    首先将dll加入language independent--->operation system independent里面.
    先声明:
    #define DLL_FILE  "Setup00.dll"
        
    ////////////////////// string defines //////////////////////////////////////////////// installation declarations ///////////////////// ----- DLL function prototypes -----
        // your DLL function prototypes
    // ---- script function prototypes -----
        // your script function prototypes
        prototype INT Setup00.Test(BYREF STRING,INT);
        // your global variables
        STRING szDLL, svString; 
    INT nValue; 
    POINTER psvString; 
    BOOL bDone; 
    //NUMBER nResult; 代码调用如下:    szDLL = SUPPORTDIR ^DLL_FILE; 
    /*--------------------------------------*\ 
    * Load SETUP00.DLL into memory. 
    \*--------------------------------------*/ 
    MessageBox (szDLL, INFORMATION); 

    nResult = UseDLL (szDLL); 
    if (nResult = 0) then 
    MessageBox ("动态库调入内存成功!", INFORMATION); 
    else 
    MessageBox ("动态库调入内存失败!", INFORMATION); 
    abort;  
    endif; 
        
    AskText("请输入示例字符串:", "这是示例字符串", svString); 
    nValue = StrLength(svString); 
    nResult = Test(svString,nValue); 
     
    // 显示调用Setup00.dll中Test函数后的字符串 
    SprintfBox(INFORMATION, "调用动态库", "调用后的字符串为:%s ", svString); 

    if (UnUseDLL (szDLL) < 0) then 
    MessageBox("卸载动态库失败,仍在内存中!", SEVERE); 
    else 
    MessageBox("从内存中卸载动态库成功!",INFORMATION); 
    endif;
      

  3.   

    问题出自这:Setup Files 项中的文件没有自动更新,必须先删除,再重新加入才行,所以我以前所作的改动都没有在安装程序中体现出来。
      

  4.   

    后来测试发现,方法放在类里面调用容易成功,放在类外面调用常出错。参考一下这篇文章:
    http://www.impu.edu.cn/learner/aboutvc/installshieldselfdll.htm