有没有办法判断记事本是通过用户双击打开的,还是点TXT文件打开的? 如题,一点头绪也没有。有没有好的思路,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 知道这个有啥子用啊,点 TXT 打开时执行参数上有文件名 获取命令行参数,双击TXT有文件名参数.快捷方式打开的没参数 如果是双击打开后.再加载一个TXT文件.那这就不可能检查出来了. 通过比对work directory和exe路径,可判断:不一致则必定是通过txt打开,一致则是通过记事本exe打开 这个函数可以得到其他进程的命令行参数//获取进程的命令行参数,返回False失败,并在Command中返回错误信息,// 返回True成功,把进程的命令行及参数保存到Command中//For Win32 目标进程如果是64位要失败function GetProcessCommandLine(dwPID : DWORD; var Command : String) : Boolean;var D : DWORD; hProcess , hThread : THandle; pAddr : Pointer; Buf : array [0..MAX_PATH-1] of WideChar;begin Result := False; pAddr := Windows.GetProcAddress(Windows.GetModuleHandle(kernel32) , 'GetCommandLineW'); if pAddr=NIL then begin Command := SysErrorMessage(GetLastError()); exit; end; hProcess := Windows.OpenProcess(PROCESS_CREATE_THREAD or PROCESS_VM_READ or PROCESS_QUERY_INFORMATION , False , dwPID); if hProcess=0 then begin Command := SysErrorMessage(GetLastError()); exit; end; hThread := Windows.CreateRemoteThread(hProcess , NIL , 0 , pAddr , NIL , 0 , D); if hThread=0 then begin CloseHandle(hProcess); Command := SysErrorMessage(GetLastError()); exit; end; Windows.WaitForSingleObject(hThread , 1000); Windows.GetExitCodeThread(hThread , D); FillChar(Buf , SizeOf(Buf) , 0); Windows.ReadProcessMemory(hProcess , Ptr(D) , @Buf , SizeOf(Buf) , D); Command := Trim(Buf); CloseHandle(hProcess); CloseHandle(hThread);end; CloseHandle(hProcess); CloseHandle(hThread); Result := True; //加上这一行end; windows编程里的。 FastMM4.92测试报告! 又来打搅大家了,通过dll操作delphi控件的问题,200分送上 关于EDIT控件输入长度的限制方法 DELPHI窗体最大化以后布局变形的问题 谁知道那里有delphi的帮助资料 如何将文字用二进制表示,并可以还原? 如何把Variant转换为类变量(com编程) qrdbtext折行显示后如何控制行间距大小啊? 在Delphi中如何使用第三方控件? 请问:怎么才能知道一个路径是指向文件还是指向目录? delphi xe5 android利用datasnap将照片传到MSSQL,传不进去,大神们跪求帮忙 求窗体界面左侧级联菜单控件 见附件截图
快捷方式打开的没参数
//获取进程的命令行参数,返回False失败,并在Command中返回错误信息,
// 返回True成功,把进程的命令行及参数保存到Command中
//For Win32 目标进程如果是64位要失败
function GetProcessCommandLine(dwPID : DWORD; var Command : String) : Boolean;
var
D : DWORD;
hProcess , hThread : THandle;
pAddr : Pointer;
Buf : array [0..MAX_PATH-1] of WideChar;
begin
Result := False;
pAddr := Windows.GetProcAddress(Windows.GetModuleHandle(kernel32) , 'GetCommandLineW');
if pAddr=NIL then begin
Command := SysErrorMessage(GetLastError());
exit;
end;
hProcess := Windows.OpenProcess(PROCESS_CREATE_THREAD or PROCESS_VM_READ or PROCESS_QUERY_INFORMATION , False , dwPID);
if hProcess=0 then begin
Command := SysErrorMessage(GetLastError());
exit;
end;
hThread := Windows.CreateRemoteThread(hProcess , NIL , 0 , pAddr , NIL , 0 , D);
if hThread=0 then begin
CloseHandle(hProcess);
Command := SysErrorMessage(GetLastError());
exit;
end;
Windows.WaitForSingleObject(hThread , 1000);
Windows.GetExitCodeThread(hThread , D);
FillChar(Buf , SizeOf(Buf) , 0);
Windows.ReadProcessMemory(hProcess , Ptr(D) , @Buf , SizeOf(Buf) , D);
Command := Trim(Buf);
CloseHandle(hProcess);
CloseHandle(hThread);
end;
CloseHandle(hThread);
Result := True; //加上这一行
end;