可能重複:
How to list all installed ActiveX controls?如何獲取用戶系統上可用的ActiveX列表?
我想獲得可用的ActiveX的完整列表,用戶系統上的控制。就像當你想導入一個activeX時delphi所做的一樣。 (它顯示一個列表)
問候, Javid
可能重複:
How to list all installed ActiveX controls?如何獲取用戶系統上可用的ActiveX列表?
我想獲得可用的ActiveX的完整列表,用戶系統上的控制。就像當你想導入一個activeX時delphi所做的一樣。 (它顯示一個列表)
問候, Javid
這是我寫的我自己。只需添加Registry
單位,你就完成了!
procedure GetActiveXObjects(List: TStringList);
procedure KeyNotFound;
begin
raise exception.create('Key not found.');
end;
const
PATH = 'Software\\Classes\\TypeLib\\';
var
R: TRegistry;
S1, S2: TStringList;
S, Output: String;
begin
List.Clear;
try
S1 := TStringList.Create;
S2 := TStringList.Create;
R := TRegistry.create(KEY_READ);
R.RootKey := HKEY_LOCAL_MACHINE;
if (not R.OpenKey(PATH, False)) then
KeyNotFound;
R.GetKeyNames(S1);
for S in S1 do begin
// Position: CLSID
R.CloseKey;
if (not R.OpenKeyReadOnly(PATH + S + '\\')) then
Continue;
R.GetKeyNames(S2);
// Position:Version
if (S2.Text = '') or (not R.OpenKeyReadOnly(S2.Strings[0])) then
Continue;
Output := R.ReadString('');
if Output <> '' then
List.Add(Output);
end;
finally
R.Free;
S1.Free;
S2.Free;
end;
end;
這裏是你想要的(幾乎)是C++版本。你會得到所有課程的清單。它猜測Delphi中的ActiveX導入嚮導對每個庫都有一行。 How to list all installed ActiveX controls?
在德爾福你可以做這樣的事情。
const
CATID_Control: TGUID = '{40FC6ED4-2438-11cf-A3DB-080036F12502}';
procedure GetActiveXControlList(List: TStringList);
var
catInfo: ICatInformation;
enumGuid: IEnumGUID;
ClassID: TGUID;
Fetched: Cardinal;
Name: PWideChar;
begin
OleCheck(CoCreateInstance(CLSID_StdComponentCategoryMgr, nil,
CLSCTX_INPROC_SERVER, ICatInformation, CatInfo));
catInfo.EnumClassesOfCategories(1, @CATID_Control, 0, @GUID_NULL, EnumGUID);
while enumGuid.Next(1, ClassID, Fetched) = S_OK do
begin
OleCheck(OleRegGetUserType(ClassID, USERCLASSTYPE_FULL, Name));
List.Add(Name);
end;
end;
你不應該發佈帶有重複鏈接的答案。你應該投票結束,因爲確切的重複! – 2011-03-07 21:26:19
這是相當多的PowerShell solution from Jeff Atwood的直接端口:
procedure GetActiveXObjects(strings : TStrings);
const
BASE_KEY = '\Software\Classes';
var
reg : TRegistry;
keys : TStrings;
regex : TPerlRegEx;
key : String;
begin
strings.Clear;
keys := nil;
regex := nil;
reg := TRegistry.Create;
try
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.OpenKeyReadOnly(BASE_KEY);
keys := TStringList.Create;
reg.GetKeyNames(keys);
regex := TPerlRegEx.Create;
regex.RegEx := '^\w+\.\w+$';
for key in keys do
begin
regex.Subject := key;
if regex.Match and reg.KeyExists(BASE_KEY + '\' + key + '\CLSID') then
strings.Add(key)
end;
finally
reg.Free;
keys.Free;
regex.Free;
end;
end;
http://stackoverflow.com/questions/1649171/how-to-list-all-activex-controls的副本? – RBA 2011-03-07 08:19:00
我想用Delphi來做到這一點。我想用編碼來做,而不是用外部的東西。 – Javid 2011-03-07 09:07:30
它似乎是一個愚蠢的,但不同的[問題](http://stackoverflow.com/questions/2755351/)。從好的一面來看,這確實回答了你的問題! – 2011-03-07 10:01:15