[英]Using AssocQueryString to get 64-bit application command from 32-bit application, but not working
I try to use AssocQueryString to get association information, myapp.exe is 32-bit executable file. 我尝试使用AssocQueryString获取关联信息,myapp.exe是32位可执行文件。 Here's my code. 这是我的代码。
WCHAR commandline[_MAX_PATH];
DWORD size = _MAX_PATH;
HRESULT h = AssocQueryStringW(ASSOCF_OPEN_BYEXENAME, ASSOCSTR_COMMAND, execName, 0, commandline, &size);
if (SUCCEEDED(h))
{
...
}
I find that if "execName" is a 32-bit application, this api works perfect. 我发现,如果“ execName”是32位应用程序,则此api可以完美运行。 For example, 例如,
WCHAR *execName = L"mspaint.exe";
We can get command = "C:\\Windows\\system32\\mspaint.exe" "%1" 我们可以得到命令=“ C:\\ Windows \\ system32 \\ mspaint.exe”“%1”
But if giving a 64-bit application(ex: PaintDotNet.exe), SUCCEEDED(h) would return FALSE. 但是,如果提供64位应用程序(例如:PaintDotNet.exe),则SUCCEEDED(h)将返回FALSE。 Variable h = 0x80070483, which means "no application is associated with the file extension". 变量h = 0x80070483,表示“没有应用程序与文件扩展名关联”。
Since above observation, I guess this api may fail when trying to get 64-bit application information. 由于上述观察,我猜想此api在尝试获取64位应用程序信息时可能会失败。
So my question are: 所以我的问题是:
Is there anything I ignore or wrong usage of AssocQueryString? 有什么我忽略或错误使用AssocQueryString的东西吗?
Is there another way to get a 64-bit app info from a 32-bit app? 还有另一种方法可以从32位应用程序获取64位应用程序信息吗?
By the way, I don't want to just compile my app as a 64-bit app. 顺便说一句,我不想只是将我的应用程序编译为64位应用程序。
Thank you for all your help. 谢谢你的帮助。
1. Is there anything I ignore or wrong usage of AssocQueryString? 1.有什么我忽略或错误使用AssocQueryString的东西吗?
1) ASSOCSTR_COMMAND replace to ASSOCSTR_EXECUTABLE 1)将ASSOCSTR_COMMAND替换为ASSOCSTR_EXECUTABLE
and you can get just "C:\\Windows\\system32\\mspaint.exe" 您可以只获取“ C:\\ Windows \\ system32 \\ mspaint.exe”
2) SUCCEEDED is non-negative numbers indicate true 2)SUCCEEDED是非负数表示正确
(((HRESULT)(hr)) >= 0) ((((HRESULT)(hr))> = 0)
so if you check success, check result equal zero 因此,如果您检查成功,则检查结果等于零
2. Is there another way to get a 64-bit app info from a 32-bit app? 2.还有其他方法可以从32位应用程序获取64位应用程序信息吗?
1) if your windows x64, folder C:\\Windows\\system32\\ is for 64bit files. 1)如果Windows x64文件夹C:\\ Windows \\ system32 \\用于64位文件。
cf> http://www.samlogic.net/articles/32-64-bit-windows-folder-x86-syswow64.htm C:\\Windows\\System32 Windows System folder (system directory) for 64-bit files C:\\Windows\\SysWOW64 Windows System folder (system directory) for 32-bit files cf> http://www.samlogic.net/articles/32-64-bit-windows-folder-x86-syswow64.htm C:\\ Windows \\ System32 Windows系统文件夹(系统目录),用于64位文件C:\\ Windows \\ SysWOW64 Windows系统文件夹(系统目录),用于32位文件
2) just check result equal zero, and print it. 2)只需检查结果等于零,然后打印出来。 do not use SUCCEEDED(h) in this case. 在这种情况下,请勿使用SUCCEEDED(h)。
AssocQueryString's return value S_OK(0), E_POINTER, S_FALSE(1) AssocQueryString的返回值S_OK(0),E_POINTER,S_FALSE(1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.