简体   繁体   English

访问rc文件中的字符串

[英]Accessing strings in an rc file

I have an rc file conating a string table that is in a dll say X. 我有一个rc文件连接一个dll中的字符串表,说X。

I wish to use the strings in this string table in a C# project say Y present in the same solution. 我希望在同一解决方案中使用的C#项目中使用此字符串表中的字符串。 If the project Y was C++, I know you can use LoadString function, but for C#, I am not sure. 如果项目Y是C ++,我知道您可以使用LoadString函数,但是对于C#,我不确定。

Can you list out the steps needed? 您可以列出所需的步骤吗?

You can still use LoadString thanks to P-Invoke 借助P-Invoke,您仍然可以使用LoadString

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int LoadString(IntPtr hInstance, uint uID,StringBuilder lpBuffer, int nBufferMax);

Here also defintions of LoadLibrary and FreeLibrary 这里还定义了LoadLibraryFreeLibrary

[DllImport("kernel32", SetLastError=true, CharSet = CharSet.Unicode)]
static extern IntPtr LoadLibraryA(string lpFileName);

[DllImport("kernel32.dll", SetLastError=true)]
static extern bool FreeLibrary(IntPtr hModule);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM