本文介绍了C#中的UpdateResource?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在C#中通过P/Invoke使用UpdateResource?
Ther的任何其他功能都可以更新c#中的exe文件,例如UpdateResource ??
我使用Google搜索,但找不到我想要的东西?
Hi,
How to use UpdateResource in c# with P/Invoke??
Ther''s any other function that allow to update exe file in c# like UpdateResource??
I used google search but i can''t found what i want??
推荐答案
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool UpdateResource(IntPtr hUpdate, string lpType, string lpName, ushort wLanguage,
IntPtr lpData, uint cbData);
You might access this API like,
IntPtr handleExe = BeginUpdateResource(exeFilePath, false);
CultureInfo currentCulture = CultureInfo.CurrentCulture;
int pid = ((ushort)currentCulture.LCID) & 0x3ff;
int sid = ((ushort)currentCulture.LCID) >> 10;
ushort languageID = (ushort)((((ushort)pid) << 10) | ((ushort)sid));
GCHandle iconHandle = GCHandle.Alloc(resourceData, GCHandleType.Pinned);
然后,您可以通过发送这些参数来调用 UpdateResource .
如果您想了解每个参数的说明,则可能会看到以下 [链接].
Then you might call UpdateResource by sending those parameters.
If you want to know the explanation of each parameter you might see this [link].
这篇关于C#中的UpdateResource?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!