如何以编程方式(winapi)了解args列表,在程序启动时通过命令行给出?
答案 0 :(得分:5)
要使用WinAPI从外部进程获取命令行,您必须访问应用程序的PEB (Process Environment Block)。要获取PEB,您可以使用NtQueryInformationProcess
函数,也可以使用Win32_Process
WMI类和CommandLine
属性。您可以在本文"Two ways to get the command line of another process"上找到这两种方法的示例。另请参阅Raymond Chen撰写的这篇文章"How do I get the command line of another process?",其中提供了有关命令行缓冲区可靠性的非常重要的信息。