0

我有一个与 PDW 一起分发的旧 VB6 应用程序。我需要在安装后确定它是否是应用程序的第一次运行。最简单的方法是什么?

目前,我安装了一个虚拟文本文件并使用它的存在作为首次运行的证据。如果 firstrun.txt 在 app 目录中,我打开一个子例程,创建一些目录并复制一些文件,然后删除 txt 文件。下一次,它会跳过子例程,因为 firstrun.txt 不存在。在用户收到错误代码 70 之前完美运行,因为他们没有删除文件的适当权限。

这是我用来删除文本文件的代码:

mobjFSO.DeleteFile App.Path & "\firstrun.txt

Anyone have a better way? Or could someone tell me how to allow the program to delete the file regardless of permisson?

Thanks in advance!

4

1 回答 1

2

Try the opposite approach. If no file exists, assume it is the first run. After the first run does its thing, write a file -- but write it to a user area, such as C:\Users\myuser\AppData on Windows. This would be a more appropriate place to store this kind of data and you won't suffer the same permissions issues.

于 2013-03-29T20:21:38.220 回答