c++ - 确定我的应用程序何时首次运行

标签 c++ algorithm winapi

我有一个本地 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/

相关文章:

c++ - 函数调用顺序错误

python - 使用一个 C 程序运行 python 脚本(不同的 python 版本)

c++ - eclipse-cdt如何与静态库链接

algorithm - 使用模的 while 循环的时间复杂度

c++ - Qt 5- QTextEdit 恢复为默认字体

java - 为什么第一个 sqrt 算法比第二个更快?

c++ - 计算定点数的 sin() 和 cos() 的简单三角算法

c# - 如何添加系统 "windows hook"以便在创建/激活窗口时收到通知?

c++ - 如何将 win32 窗口渲染为 opengl 纹理?

c++ - Winapi 专用鼠标/键盘