运行 C 程序作为替换 Windows shell 时似乎无法打开文件
关于这个令人困惑的问题的一些简单背景知识——我正在制作一款运行 Windows XP 作为操作系统的街机游戏。我试图隐藏这样一个事实:它正在运行 Windows,将所有内容涂黑,隐藏光标,并用我的游戏可执行文件替换 Windows shell(因此没有任务栏)。我使用 gpedit.msc 执行此操作,本地计算机策略>>用户配置>>>行政。模板>>系统>>自定义用户界面,并将我的游戏的 EXE 指定为自定义用户界面程序。这正是某些人在制作 MAME 街机时所做的事情,指定加载前端而不是 Explorer.exe。 我 我遇到的问题是,当我的程序设置为作为自定义用户界面/外壳运行时,它无法打开文件。当我的程序尝试打开数据文件时,fopen 每次都返回 NULL。但是,发生这种情况后,如果我启动任务管理器并手动运行相同的程序作为新任务,文件就可以正常打开。此外,如果我不使用我的程序作为自定义用户界面,而是指定一个运行我的程序的批处理文件,那么该程序就可以很好地打开文件。我不想走这条路,因为命令提示符会出现,而且很明显它是一个 Windows 框。我什至尝试使用脚本隐藏该命令提示符,但这不起作用。
为了进一步解决这个问题,我编写了一个程序,仅使用 stdio(而不是我的游戏库,以隔离它)来简单地打开一个存在的文本文件,并报告是否成功打开该文件。当作为自定义用户界面运行时,它无法打开文件,但一旦登录并手动运行,它就可以打开文件了!对我所缺少的任何帮助将不胜感激!谢谢!
Some quick background on this baffling problem -- I'm making an arcade game that will run Windows XP as its OS. I'm trying to hide the fact that it's running Windows blacking everything out, hiding the cursor, and replacing the Windows shell with my game's executable (so there's no taskbar). I do this using gpedit.msc, Local Computer Policy >> User Config. >> Admin. Templates >> System >> Custom User Interface, and specifying my game's EXE as the custom user interface program. This is just what some do when making MAME arcades, specifying a front end that loads instead of Explorer.exe.
l
The problem I'm encountering is that my program is unable to open files when it's setup to run as a custom user interface/shell. When a data file is attempted to be opened by my program, fopen returns NULL every time. However, after this happens, if I start task manager and run the same program manually as a new task, files are able to open just fine. In addition, if instead of using my program as a custom user interface, I instead specify a batch file that runs my program, then the program is able to open files just fine. I'd prefer not to go that route as then the command prompt appears and it's obvious it's a Windows box. I even tried hiding that command prompt using scripting and that didn't work.
To troubleshoot this further I wrote a program just using stdio (and not my game library, to isolate this) to simply open a text file that exists and report whether it was successful in opening the file or not. When run as a custom user interface it cannot open the file, but once logged in and manually run, it can open the file just fine! Any help on what I'm missing would be GREATLY appreciated! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论