访问数据的 NSIS 问题 [英] NSIS problem accessing data

查看:28
本文介绍了访问数据的 NSIS 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会尽量让自己清楚.

我用 NSIS 制作了一个安装程序.在桌面上创建了一个图标,当我双击它时,应用程序运行良好.但是,在安装目录中,我还有其他目录(例如包含style.css"的css"),而且程序似乎正在快捷方式(-> 桌面)的目录中查找我的 css 文件.

如何让程序在安装目录中而不是在桌面中查找?

感谢您的回答.

<小时>

这是我使用的代码:

快捷方式"部分第2节SetOutPath "$SMPROGRAMS\MyApp"CreateShortCut "$SMPROGRAMS\MyApp\MyApp.lnk" "$INSTDIR\MyApp.exe"设置输出路径$INSTDIR"CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\MyApp.exe"节末

如果我将 outpath(第 3 行)更改为$INSTDIR",则根本不会创建快捷方式.如果我使用此代码,则会创建快捷方式,但将开始于"参数设置为桌面.

解决方案

这种情况下的问题是您的应用程序使用了相对路径而没有限定它们;简单的解决方案是让快捷方式指定工作目录:(SetOutPath 改变了 CreateShortCut 似乎很奇怪,但手册说它确实如此)

SetOutPath "$INSTDIR"CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\MyApp.exe" # etc.

正确的解决方案是将所有路径设为绝对路径;您已将其标记为 qt,因此我认为您正在使用 Qt 和 C++.搜索qt绝对路径"之类的东西 - 例如Qt-interest Archive - 如何获取应用的绝对路径?

I'll try to make myself as clear as possible.

I made an installation program with NSIS. An icon was created on the desktop and when I double-click it, the application lanches well. However, in the install directory I have other directories (like "css" which contains "style.css"), and it seems that the program is looking for my css file in the directory of the shortcut (-> desktop).

How could I make the program looking in the install directory rather than in the desktop ?

Thanks for your answers.


Here is the code I used :

Section "Shortcuts"
SectionIn 2 
SetOutPath "$SMPROGRAMS\MyApp"
CreateShortCut "$SMPROGRAMS\MyApp\MyApp.lnk" "$INSTDIR\MyApp.exe"
SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\MyApp.exe"
SectionEnd 

If I change the outpath (line 3) to "$INSTDIR", the shortcut isn't created at all. If I use this code, the shortcut is created but the "start in" parameter is set to the desktop.

解决方案

The problem in this case is that your application is using relative paths without qualifying them; the simple solution is to have the shortcut specify the working directory: (it seems strange that the SetOutPath alters the CreateShortCut, but the manual says it does)

SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\MyApp.exe" # etc.

The proper solution is to make all paths absolute; you've tagged it as qt so I presume you're using Qt and C++. Search around for "qt absolute path" and things like that - e.g. Qt-interest Archive - How to get an application's absolute path?

这篇关于访问数据的 NSIS 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆