我有一个本地 WinApi C++ 应用程序,可以在指定目录中查找媒体(.wmv、.mp3 等)文件并创建随机播放列表。应用程序第一次运行时(而且只是第一次)我想提示用户指定一个“主”目录,应用程序将始终检查媒体文件并从中创建播放列表。
我的问题:我不知道如何确定应用程序何时第一次运行?
有没有一种标准的方法,也许是一个 Win32 函数,我可以使用它来检测应用程序何时第一次运行?
我提出的一些想法是:(但它们看起来像是 hack 或矫枉过正(安装程序想法))
- The application .exe is 322kb(which is tiny & doesn't require an installer right?) in size so I could create an installer (I was thinking if someone is installing the application then I know its the first run & I can prompt them then).
- I could have a text file(or xml) called appData.txt & have the 1st line where I store the home path directory. So "home_path=undefined", on application run, I look in the text file, if the home_path == undefined then I prompt them to specify a home path if its not undefined then I read that directory for media files.
关于如何确定我的应用程序何时首次运行的任何想法?
最佳答案
在安装程序中,您可以为您的程序创建一个注册表值。
然后当您启动程序时,检查注册表值。
当您第一次运行该程序时,将该值更新为以便您知道它已经运行过。
关于c++ - 确定我的应用程序何时首次运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7213571/