dll中函数声明
int __stdcall XnfsCtrl_Install(int bNowStartDriver, char *szDriverFilePath)
我在nsis脚本中调用该函数的写法
StrCpy $0 1
StrCpy $1 "$INSTDIRSHSecdrv.sys"
StrCpy $2 ""
System::Call '$INSTDIRCommSecDoc.dll::XnfsCtrl_Install(i , t) i(r0,r1).r2'
我这个函数是第三方dll装他提供的驱动的, 我安装的过程已经把dll和驱动都解压到安装目录下了,这样调用
r2返回值一直 是 error
不知道哪写错了,帮助文档瞧了好几遍就是没瞧懂
哪位大神给指点指点啊,是不是这被调用的dll有什么特殊要求什么的
回复讨论(解决方案)
你确定$INSTDIRCommSecDoc.dll存在?
你确定$INSTDIRCommSecDoc.dll存在?
我用Messagebox 停下来 在那安装目录是有那个dll的
肯定没错的,vc代码里调用是没问题的
请问怎样查看错误信息了,返回值 书出来就 error
这个dll是用来与 驱动 irp通信用的,不依赖其他另外的非系统dll了
; 该脚本使用 HM VNISEdit 脚本编辑器向导产生
!AddPluginDir .
; 安装程序初始定义常量
!define PRODUCT_NAME "TEST"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_WEB_SITE ""
!define PRODUCT_DIR_REGKEY "SoftwareMicrosoftWindowsCurrentVersionApp PathsTEST.exe"
!define PRODUCT_UNINST_KEY "SoftwareMicrosoftWindowsCurrentVersionUninstall${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
SetCompressor lzma
; ------ MUI 现代界面定义 (1.67 版本以上兼容) ------
!include "MUI.nsh"
; MUI 预定义常量
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}ContribGraphicsIconsmodern-install.ico"
!define MUI_UNICON "${NSISDIR}ContribGraphicsIconsmodern-uninstall.ico"
; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
; 安装目录选择页面
!insertmacro MUI_PAGE_DIRECTORY
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!insertmacro MUI_PAGE_FINISH
; 安装卸载过程页面
!insertmacro MUI_UNPAGE_INSTFILES
; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "SimpChinese"
; 安装预释放文件
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; ------ MUI 现代界面定义结束 ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILESHWSFM"
InstallDirRegKey HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
ShowInstDetails show
ShowUnInstDetails show
BrandingText "TEST"
RequestExecutionLevel admin
Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "G:TESTReleaseTEST.exe"
CreateDirectory "$SMPROGRAMSTEST"
CreateShortCut "$SMPROGRAMSHWSFMTEST.lnk" "$INSTDIRTEST.exe"
CreateShortCut "$DESKTOPTEST.lnk" "$INSTDIRTEST.exe"
File "G:TESTReleaseCommSecDoc.dll"
File "G:TESTReleaseSHSecdrv.sys"
SectionEnd
Section -AdditionalIcons
SetOutPath $INSTDIR
CreateShortCut "$SMPROGRAMSHWSFMUninstall.lnk" "$INSTDIRuninst.exe"
StrCpy $0 1
StrCpy $1 "$INSTDIRSHSecdrv.sys"
StrCpy $2 ""
System::Call '$INSTDIRCommSecDoc.dll::XnfsCtrl_Install(i , t) i(r0,r1).r2'
MessageBox MB_YESNO "提示:R0:$0,R1:$1,R2:$2"
SectionEnd
Section -Post
;写卸载注册表
SectionEnd
代码是向导生成的 我只在Section -AdditionalIcons 添加了部分的代码
如果在TEST.EXE启动时直接调用安装函数,那样把3个文件打包是可以直接用的
不行我就只能继续完善我那win32写的安装包了
SetOutPath $INSTDIR
File CommSecDoc.dll
System::Call 'CommSecDoc::XnfsCtrl_Install(i1, t"$INSTDIRSHSecdrv.sys")i.r2'
${If} $2 == "error"
System::Call Kernel32::GetLastError()i.r2
MessageBox MB_ICONINFORMATION|MB_OK "$2"
${EndIf}
我就知道下面这两种情况肯定是返回error的
The specified module could not be found. ERROR_MOD_NOT_FOUND
The specified procedure could not be found. ERROR_PROC_NOT_FOUND
SetOutPath $INSTDIR
File CommSecDoc.dll
System::Call 'CommSecDoc::XnfsCtrl_Install(i1, t"$INSTDIRSHSecdrv.sys")i.r2'
${If} $2 == "error"
System::Call Kernel32::GetLastError()i.r2
MessageBox MB_ICONINFORMATION|MB_OK "$2"
${EndIf}
我就知道下面这两种情况肯定是返回error的
The specified module could not be found. ERROR_MOD_NOT_FOUND
The specified procedure could not be found. ERROR_PROC_NOT_FOUND
谢谢楼上的提醒,让我突然想起这个dll是不是没有导出函数名,无法被 System::call 查找到函数从而无法调用,结果用depands一看还真是的。。唉,有时候脑子真转不过弯来,一直以为是nsis脚本没写对
好了,结贴了,既然脚本没写错,就只能另想办法了
LIBRARY CommSecDoc
EXPORTS
XnfsCtrl_Install
暂无评论内容