Windows CE C#에서 프로그램 경로 얻어오기
private const uint HKEY_LOCAL_MACHINE = 0x80000002;
[DllImport("CoreDll.dll", SetLastError = true)]
private static extern IntPtr GetModuleHandle(IntPtr ModuleName);
[DllImport("CoreDll.dll", SetLastError = true)]
private static extern Int32 GetModuleFileName(IntPtr hModule, StringBuilder ModuleName, Int32 cch);
public static string GetEntryAssembly()
{
StringBuilder fn = null;
IntPtr hModule = GetModuleHandle(IntPtr.Zero);
if (IntPtr.Zero != hModule)
{
fn = new StringBuilder(255);
if (0 == GetModuleFileName(hModule, fn, fn.Capacity))
return null;
}
return fn.ToString();
}
public static string GetEntryDirectory()
{
string assembly = GetEntryAssembly();
if (assembly == null)
return null;
int crop = assembly.LastIndexOf("\\");
if (crop > 0)
assembly = assembly.Remove(crop, assembly.Length - crop);
return assembly;
}
==========================================================
compack framework에서는 getCurrentDirectory()같은 함수를 사용할 수 없다.
하지만 돌려서 사용하는 함수를 구현해서 쓸 수 있다.