API 로 DLL 등록
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | using System.Runtime.InteropServices; ... [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void _DLLPROC(); [DllImport("kernel32.dll", EntryPoint = "LoadLibrary")] private extern static int LoadLibrary(string librayName); [DllImport("kernel32.dll", EntryPoint = "GetProcAddress", CharSet = CharSet.Ansi)] private extern static IntPtr GetProcAddress(int hwnd, string procedureName); ... public void DLLRegister(string DLLPath) { if (System.IO.File.Exists(DLLPath)) { int hMod = LoadLibrary(DLLPath); if (hMod != 0) { _DLLPROC dllProc; IntPtr pfnDllProc = GetProcAddress(hMod, "DllRegisterServer"); if (pfnDllProc != IntPtr.Zero) { dllProc = (_DLLPROC)Marshal.GetDelegateForFunctionPointer(pfnDllProc, typeof(_DLLPROC)); dllProc(); } } } } | cs |
'Dev::DotNet > C#' 카테고리의 다른 글
new 한정자(new Modifier) (0) | 2013.12.23 |
---|---|
확장 메소드(Extension Methods) (0) | 2013.11.26 |
Google gmail 로 메일 보내기 - c#, smtp (0) | 2013.10.31 |
마우스 이동에 따른 화면 이동 (0) | 2013.10.29 |
GZipStream 을 이용한 문자열 압축 (0) | 2013.10.28 |