注册DLL的API函数是什么?

CALM 2002-08-19 09:52:59
有没有例子呀?我不是想要那个什么regsvr32的方法,我记得好象是LoadLibrary?
但是实在是不知道怎么用,真是不好意思,有谁来帮帮忙?
...全文
40 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
CALM 2002-08-19
楼上两位给我的例子好象是调用DLL的方法啊,我需要的是注册DLL的方法
GetProcAddress不是找到DLL中函数地址的API么?
回复
CALM 2002-08-19
as you known,"regsvr32" does not work well sometimes
回复
vqunjian 2002-08-19
HINSTANCE hLib = LoadLibrary(pszDllName);

if (hLib < (HINSTANCE)HINSTANCE_ERROR)
{
DisplayMessage(IDS_LOADLIBFAILED, pszDllName); //unable to load DLL
iReturn = FAIL_LOAD; //unable to load DLL
}

// Find the entry point.
(FARPROC&)lpDllEntryPoint = GetProcAddress(hLib,
_T(“DllRegisterServer”));
if (lpDllEntryPoint != NULL)
(*lpDllEntryPoint)();
else
//unable to locate entry point

回复
saucer 2002-08-19
sorry, try something like

Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long

Private Declare Function LoadLibrary Lib "kernel32" Alias
"LoadLibraryA" (ByVal lpLibFileName As String) As Long

Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long

Private Declare Function CallWindowProc Lib "user32" Alias
"CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long,
ByVal Msg As Any, ByVal wParam As Any, ByVal lParam As Any) As Long

Private Const ERROR_SUCCESS = &H0

Dim lb As Long, pa As Long
lb = LoadLibrary(DllServerPath) 'change DllServerPath to the Path to your DLL

pa = GetProcAddress(lb, "DllRegisterServer")

If CallWindowProc(pa, hWnd, ByVal 0&, ByVal 0&, ByVal 0&) =
ERROR_SUCCESS Then
MsgBox "Successful"
End If

FreeLibrary lb

actually, you could just call
shell "regsv32 " & PathToYourDLL
回复
saucer 2002-08-19
HOWTO: Programmatically Register and Unregister .OCX Files
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q173091&
回复
CALM 2002-08-19
而且按照这个方法在win98下面会出错误
回复
相关推荐
发帖
API
创建于2007-09-28

1466

社区成员

VB API
申请成为版主
帖子事件
创建了帖子
2002-08-19 09:52
社区公告
暂无公告