pb中注册ocx控件

liubocy 2006-12-01 12:21:29
用run方法会弹出提示。
现在考虑的方法如下:
API申明:
Function ulong LoadLibrary(ref string lpLibFileName) LIBRARY "kernel32.dll" ALIAS FOR "LoadLibraryA"

Function ulong GetProcAddress(ulong hModule,ref string lpProcName) LIBRARY "kernel32.dll"


CODE:
string ls_docname, ls_named, ls_FileName
integer li_value
ulong lu_LoadLibrary, lu_GetProcAddress

li_value = GetFileOpenName("选择注册控件", &
+ ls_docname, ls_named, "OCX", &
+ "OCX Files (*.OCX),*.OCX,")

IF li_value <> 1 THEN RETURN
lu_LoadLibrary = LoadLibrary( ls_docname )
IF lu_LoadLibrary > 0 THEN
ls_FileName = 'DllRegisterServer'
lu_GetProcAddress = GetProcAddress( lu_LoadLibrary, ls_FileName )
IF lu_GetProcAddress > 0 THEN
/****?****/
END IF
ELSE
MessageBox( '', '装载DLL/OCX文件错误' )
RETURN
END IF


-------------------------------------------------------------------------
想法是通过GetProcAddress函数得到控件中的注册函数DllRegisterServer的入口,然后再调用这个函数来实现注册空间的功能。但在/****?****/处就不知道如何做了
请帮忙看看!


...全文
485 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
liubocy 2006-12-03
  • 打赏
  • 举报
回复
ding
lovelihp 2006-12-02
  • 打赏
  • 举报
回复
帮顶来了
liubocy 2006-12-02
  • 打赏
  • 举报
回复
顶起吧
liubocy 2006-12-01
  • 打赏
  • 举报
回复
这个是一个相关文档:

typedef BOOL (CALLBACK *inshook)();
inshook instwnhook;

if(hinstDLL=LoadLibrary((LPCTSTR)"a.dll"))
{
instwnhook=(inshook)GetProcAddress(hinstDLL,"fun");
instwnhook();
}
liyi830 2006-12-01
  • 打赏
  • 举报
回复
mark
liubocy 2006-12-01
  • 打赏
  • 举报
回复
TO : sdhylj(青锋--SS)
说我升星了,我还纳闷呢,原来 呵呵
liubocy 2006-12-01
  • 打赏
  • 举报
回复
这是用Delphi做一个的Dll:

library RegOcx;

{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }

uses
SysUtils,
Windows,
Classes;

type
TOleRegisterFunction = function: HResult;

{$R *.res}

function RegOcxFile(OcxFileName: PChar): PChar; stdcall;
var
hLibraryHandle: THandle;
hFunctionAddress: TFarProc;
RegFunction: TOleRegisterFunction;
begin
hLibraryhandle:= LoadLibrary(PChar(OcxFileName));

try
if (hLibraryHandle > 0) then
hFunctionAddress:= GetProcAddress(hLibraryhandle,PChar(
'DllRegisterServer'))
else
begin
Result:= PChar('装载DLL/OCX文件错误');
Exit;
end;

if (hFunctionAddress <> nil) then
begin
RegFunction:= TOleRegisterFunction(hFunctionAddress);

if RegFunction < 0 then
begin
Result:= PChar('ActionX控件注册失败, Error Code:' + IntToStr(RegFunction));
Exit;
end;
end
else
begin
Result:= PChar('ActionX控件中找不到DllRegisterServer注册函数');
Exit;
end;

Result:= '0';
finally
if hLibraryHandle <> 0 then
FreeLibrary(hLibraryHandle);
end;
end;

exports
RegOcxFile name 'RegOcxFile';

begin
end.

-----------------------------------------------------------------------------
我现在只能是用pb来调用Delphi做的dll来实现注册控件的功能了。
难道就不能用pb调api来实现吗?
高手哇,给我点希望吧~
冷箫轻笛 2006-12-01
  • 打赏
  • 举报
回复
N久不用PB了,顶一下
青锋-SS 2006-12-01
  • 打赏
  • 举报
回复
连续回复可以大于3次?
青锋-SS 2006-12-01
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/TopicView3.asp?id=5199528
青锋-SS 2006-12-01
  • 打赏
  • 举报
回复
晕,搞错了,名字一样,ID不一样.
青锋-SS 2006-12-01
  • 打赏
  • 举报
回复
直接调用regsvr32不就可以了,省事.
青锋-SS 2006-12-01
  • 打赏
  • 举报
回复
楼主不错嘛,MS SQL升星了,恭喜一下.
嘿嘿,多给点分.
liubocy 2006-12-01
  • 打赏
  • 举报
回复
:(
青锋-SS 2006-12-01
  • 打赏
  • 举报
回复
哈哈.
AFIC 2006-12-01
  • 打赏
  • 举报
回复
pb没有指针,更没有函数指针,你死心把

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧