using System;
using System.Runtime.InteropServices;
[DllImport("kernel32")]
public
static
extern
IntPtr
LoadLibrary(string
lpFileName);
[DllImport("kernel32")]
public
static
extern
Boolean
FreeLibrary(IntPtr
hResModule);
[DllImport("user32.dll",
CharSet = CharSet.Unicode,
EntryPoint = "LoadStringW",
ExactSpelling = true)]
public
static
extern
int
LoadString(
IntPtr
hInstance,
uint
uID,
StringBuilder
lpBuffer,
int
nBufferMax);
public
static
String
GetStringResource(IntPtr
hModuleInstance, uint
uiStringID)
{
StringBuilder
sb = new
StringBuilder(255);
LoadString(hModuleInstance, uiStringID, sb, sb.Capacity + 1);
return
sb.ToString();
}
public static
string
GetWin32Resource(string
componentName, uint
uiResourceId)
{
string
str = string.Empty;
IntPtr
hMod = LoadLibrary(@"***\test.dll");
if (hMod !=
null)
{
str = GetStringResource(hMod, uiResourceId);
FreeLibrary(hMod);
}
return
str;
}