delphi 注册 com 对象的方法
来源:互联网 发布:美国网络实名制 编辑:程序博客网 时间:2024/04/26 10:34
delphi 注册 com 对象的方法
procedure TForm1.Button3Click(Sender: TObject);
var
Sd: TSecurityDescriptor;
begin
InitializeSecurityDescriptor(@Sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(@Sd, true, Nil, false);
RegSetPrivilege(HKEY_LOCAL_MACHINE, 'testcom', @Sd, false);
RegSetPrivilege(HKEY_CLASSES_ROOT, 'xmllib.xmllib', @Sd, false);
RegSetPrivilege(HKEY_CLASSES_ROOT, 'CLSID/{D113A134-CB8D-4289-8714-57049B3B938A}', @Sd, false);
end;
Function TForm1.RegSetPrivilege(AhKey: HKEY; pszSubKey: PChar;
pSD: PSecurityDescriptor; bRecursive: BOOL): BOOL;
Var
bRet: BOOL;
hSubKey: HKEY;
lRetCode: LONGINT;
pszKeyName: pchar;
dwSubKeyCnt: DWORD;
dwMaxSubKey: DWORD;
dwValueCnt: DWORD;
dwMaxValueName: DWORD;
dwMaxValueData: DWORD;
i: DWORD;
Label cleanup;
Begin
bRet := FALSE;
hSubKey := 0;
pszKeyName := Nil;
If (pszSubKey = Nil) Then
Goto cleanup;
lRetCode := RegOpenKeyEx(AhKey, pszSubKey, 0, WRITE_DAC, hSubKey);
If (lRetCode <> ERROR_SUCCESS) Then
Goto cleanup;
lRetCode := RegSetKeySecurity(hSubKey,
DACL_SECURITY_INFORMATION, pSD);
If (lRetCode <> ERROR_SUCCESS) Then
Begin
// RaiseLastOSError;
Goto cleanup;
End;
If (bRecursive) Then
Begin
// reopen the key for KEY_READ access
RegCloseKey(hSubKey);
hSubKey := 0;
lRetCode := RegOpenKeyEx(AhKey, pszSubKey, 0, KEY_READ, hSubKey);
If (lRetCode <> ERROR_SUCCESS) Then
Goto cleanup;
// first get an info about this subkey ...
lRetCode := RegQueryInfoKey(hSubKey, 0, 0, 0, @dwSubKeyCnt, @dwMaxSubKey,
0, @dwValueCnt, @dwMaxValueName, @dwMaxValueData, 0, 0);
If (lRetCode <> ERROR_SUCCESS) Then
Goto cleanup;
// enumerate the subkeys and call RegTreeWalk() recursivly
getmem(pszKeyName, MAX_PATH + 1);
For I := 0 To dwSubKeyCnt - 1 Do // Iterate
Begin
lRetCode := RegEnumKey(hSubKey, i, pszKeyName, MAX_PATH + 1);
If (lRetCode = ERROR_SUCCESS) Then
Begin
RegSetPrivilege(hSubKey, pszKeyName, pSD, TRUE);
End
Else If (lRetCode = ERROR_NO_MORE_ITEMS) Then
Begin
break;
End;
End;
freemem(pszKeyName);
End;
bRet := TRUE; // indicate success
cleanup:
If (hSubKey <> 0) Then
Begin
RegCloseKey(hSubKey);
End;
result := bRet;
End;
- delphi 注册 com 对象的方法
- delphi 编写的com 对象 用delphi 的调用实例
- C#的DLL注册为COM,Delphi来调用
- Delphi中Ocx的动态注册方法
- 两种注册COM组件的方法
- delphi 对象方法的调用
- COM+组件注册方法
- COM 组件注册方法
- COM+组件注册方法
- Delphi中不进行组件注册而直接调用COM对象
- 释放Com对象的方法.
- Delphi(Lazarus)怎样不注册调用COM
- delphi 编写的com 对象 用php调用的实例
- OLE/COM 对象查看器——查看已注册控件的属性和方法(自己整理)
- 不注册dll调用atl实现的com对象
- Delphi使用COM对象的时候是否需要CoInitialize
- Delphi面向对象的编程方法
- VB.net开发的com手动注册的方法
- 笔记本电脑显卡性能最新排名【2010-01-10】
- 从写线程函数时遇到的__stdcall谈起
- 客户端验证的极品--jQuery.validator
- 《赢在中国》经典语录
- 这么难
- delphi 注册 com 对象的方法
- “给”永远比“取”快乐
- 我的显示器变成一条线
- 于丹教授360个让人流泪的句子
- 关于C/C++ 表达式求值顺序 未定义
- asp.net 打包成安装程序
- ASCII,Unicode和UTF-8
- System.Data.OleDb.OleDbException: 操作必须使用一个
- Web中Input文字垂直居中的办法