在 Delphi 2011 年为 Active DS 导入类型库

Import type library for Active DS in Delphi 2011

我正在尝试向我的 Delphi 应用程序添加一些与 Active Directory 相关的功能。我的开发机器是 Azure Windows 虚拟机。

当我去导入组件时 |导入类型库 我没有将 Active DS 视为已注册的类型库。如果我单击“添加”并导航到 C:\Windows\System32,TLB 文件就在那里,但如果我尝试导入它,我会收到错误“访问 OLE 注册表时出错”和以下难以理解的细节。

如何注册并导入此类型库,以便我可以调用与活动目录相关的 Windows API?

[505AC9C0]{rtl280.bpl  } System.Win.ComObj.EOleSysError.Create (Line 1445, "System.Win.ComObj.pas" + 4) + 
[505AC9CF]{rtl280.bpl  } System.Win.ComObj.EOleSysError.Create (Line 1447, "System.Win.ComObj.pas" + 6) + [=11=]
[213B87DF]{tlib280.bpl } TlbUtils.RegisterTypeLibrary (Line 422, "TlbUtils.pas" + 3) + B
[213B8847]{tlib280.bpl } TlbUtils.LoadAndRegisterTypeLibrary (Line 430, "TlbUtils.pas" + 2) + 
[51EFFB81]{comcore280.bpl} ImportTLB.TTypeLibSelectionManager.OnAdd (Line 223, "ImportTLB.pas" + 40) + 
[20810093]{coreide280.bpl} ItemsWizardPage.TListFrame.AddButtonClick (Line 554, "ItemsWizardPage.pas" + 3) + 
[50CC8223]{vcl280.bpl  } Vcl.Controls.TControl.Click (Line 7660, "Vcl.Controls.pas" + 9) + 
[50CF03F6]{vcl280.bpl  } Vcl.StdCtrls.TCustomButton.Click (Line 5875, "Vcl.StdCtrls.pas" + 3) + 
[50CF1580]{vcl280.bpl  } Vcl.StdCtrls.TCustomButton.CNCommand (Line 6510, "Vcl.StdCtrls.pas" + 1) + $B
[50CC7CCA]{vcl280.bpl  } Vcl.Controls.TControl.WndProc (Line 7544, "Vcl.Controls.pas" + 91) + 
[50CC9782]{vcl280.bpl  } Vcl.Controls.TControl.GetStyleName (Line 8574, "Vcl.Controls.pas" + 1) + 
[50CC97AE]{vcl280.bpl  } Vcl.Controls.TControl.GetStyleName (Line 8578, "Vcl.Controls.pas" + 5) + 
[5005A36C]{rtl280.bpl  } System.@GetMem (Line 4928, "System.pas" + 20) + [=11=]
[50061FB2]{rtl280.bpl  } System.@NewUnicodeString (Line 25652, "System.pas" + 10) + [=11=]
[5006245D]{rtl280.bpl  } System.@UStrAsg (Line 26576, "System.pas" + 19) + [=11=]
[5005A388]{rtl280.bpl  } System.@FreeMem (Line 4976, "System.pas" + 20) + [=11=]
[500620D8]{rtl280.bpl  } System.@UStrArrayClr (Line 25996, "System.pas" + 9) + [=11=]
[50CC985F]{vcl280.bpl  } Vcl.Controls.TControl.IsCustomStyleActive (Line 8592, "Vcl.Controls.pas" + 8) + 
[50CCCDBD]{vcl280.bpl  } Vcl.Controls.TWinControl.WndProc (Line 10579, "Vcl.Controls.pas" + 170) + 
[50CF0068]{vcl280.bpl  } Vcl.StdCtrls.TButtonControl.WndProc (Line 5708, "Vcl.StdCtrls.pas" + 13) + 
[50CC7900]{vcl280.bpl  } Vcl.Controls.TControl.Perform (Line 7322, "Vcl.Controls.pas" + 10) + 
[50CCCF17]{vcl280.bpl  } Vcl.Controls.DoControlMsg (Line 10648, "Vcl.Controls.pas" + 12) + 
[50CCD9BB]{vcl280.bpl  } Vcl.Controls.TWinControl.WMCommand (Line 10925, "Vcl.Controls.pas" + 1) + 
[50CC7CCA]{vcl280.bpl  } Vcl.Controls.TControl.WndProc (Line 7544, "Vcl.Controls.pas" + 91) + 
[50CCCEC5]{vcl280.bpl  } Vcl.Controls.TWinControl.DefaultHandler (Line 10620, "Vcl.Controls.pas" + 30) + 
[50CC7CCA]{vcl280.bpl  } Vcl.Controls.TControl.WndProc (Line 7544, "Vcl.Controls.pas" + 91) + 
[50CC9782]{vcl280.bpl  } Vcl.Controls.TControl.GetStyleName (Line 8574, "Vcl.Controls.pas" + 1) + 
[50CC97AE]{vcl280.bpl  } Vcl.Controls.TControl.GetStyleName (Line 8578, "Vcl.Controls.pas" + 5) + 
[5005A36C]{rtl280.bpl  } System.@GetMem (Line 4928, "System.pas" + 20) + [=11=]
[50061FB2]{rtl280.bpl  } System.@NewUnicodeString (Line 25652, "System.pas" + 10) + [=11=]
[5006245D]{rtl280.bpl  } System.@UStrAsg (Line 26576, "System.pas" + 19) + [=11=]
[5005A388]{rtl280.bpl  } System.@FreeMem (Line 4976, "System.pas" + 20) + [=11=]
[500620D8]{rtl280.bpl  } System.@UStrArrayClr (Line 25996, "System.pas" + 9) + [=11=]
[50CC985F]{vcl280.bpl  } Vcl.Controls.TControl.IsCustomStyleActive (Line 8592, "Vcl.Controls.pas" + 8) + 
[50CCCDBD]{vcl280.bpl  } Vcl.Controls.TWinControl.WndProc (Line 10579, "Vcl.Controls.pas" + 170) + 
[50CC9782]{vcl280.bpl  } Vcl.Controls.TControl.GetStyleName (Line 8574, "Vcl.Controls.pas" + 1) + 
[50CC97AE]{vcl280.bpl  } Vcl.Controls.TControl.GetStyleName (Line 8578, "Vcl.Controls.pas" + 5) + 
[50CCC338]{vcl280.bpl  } Vcl.Controls.TWinControl.MainWndProc (Line 10267, "Vcl.Controls.pas" + 3) + 
[50174200]{rtl280.bpl  } System.Classes.StdWndProc (Line 18318, "System.Classes.pas" + 8) + [=11=]
[217C5B1F]{vclactnband280.bpl} Vcl.ActnMenus.CallWindowHook (Line 762, "Vcl.ActnMenus.pas" + 20) + $F
[50061544]{rtl280.bpl  } System.@TryFinallyExit (Line 23404, "System.pas" + 8) + [=11=]
[50DCDF3F]{vcl280.bpl  } Vcl.Themes.TStyleManager.GetStyle (Line 5800, "Vcl.Themes.pas" + 18) + E
[50DD15DE]{vcl280.bpl  } Vcl.Themes.TStyleHook.HandleMessage (Line 7389, "Vcl.Themes.pas" + 20) + 
[500602C7]{rtl280.bpl  } System.TObject.Dispatch (Line 18874, "System.pas" + 11) + [=11=]
[50DD1DB9]{vcl280.bpl  } Vcl.Themes.TStyleHook.WndProc (Line 7684, "Vcl.Themes.pas" + 38) + 
[50DD1F90]{vcl280.bpl  } Vcl.Themes.TMouseTrackControlStyleHook.WndProc (Line 7784, "Vcl.Themes.pas" + 0) + [=11=]
[50E1B1D9]{vcl280.bpl  } Vcl.Forms.TFormStyleHook.WndProc (Line 18214, "Vcl.Forms.pas" + 7) + 
[50CCAE2F]{vcl280.bpl  } Vcl.Controls.TWinControl.DoHandleStyleMessage (Line 9408, "Vcl.Controls.pas" + 0) + $F
[50CCCDBD]{vcl280.bpl  } Vcl.Controls.TWinControl.WndProc (Line 10579, "Vcl.Controls.pas" + 170) + 
[50CCCEC5]{vcl280.bpl  } Vcl.Controls.TWinControl.DefaultHandler (Line 10620, "Vcl.Controls.pas" + 30) + 
[50CC8670]{vcl280.bpl  } Vcl.Controls.TControl.WMLButtonUp (Line 7793, "Vcl.Controls.pas" + 1) + 
[50174200]{rtl280.bpl  } System.Classes.StdWndProc (Line 18318, "System.Classes.pas" + 8) + [=11=]
[50CC7CCA]{vcl280.bpl  } Vcl.Controls.TControl.WndProc (Line 7544, "Vcl.Controls.pas" + 91) + 
[50EF0AA3]{vcl280.bpl  } Vcl.Styles.TCustomStyle.SourceLoaded (Line 3315, "Vcl.Styles.pas" + 1) + 
[50EF09E0]{vcl280.bpl  } Vcl.Styles.TCustomStyle.GetEnabled (Line 3295, "Vcl.Styles.pas" + 0) + 
[50DCDFD3]{vcl280.bpl  } Vcl.Themes.TStyleManager.GetIsCustomStyleActive (Line 5836, "Vcl.Themes.pas" + 0) + 
[50DD223D]{vcl280.bpl  } Vcl.Themes.TCustomStyleEngine.HookCBProc (Line 7856, "Vcl.Themes.pas" + 3) + [=11=]
[50DD2417]{vcl280.bpl  } Vcl.Themes.TCustomStyleEngine.HookCBProc (Line 7921, "Vcl.Themes.pas" + 68) + 
[50CC9782]{vcl280.bpl  } Vcl.Controls.TControl.GetStyleName (Line 8574, "Vcl.Controls.pas" + 1) + 
[50CC97AE]{vcl280.bpl  } Vcl.Controls.TControl.GetStyleName (Line 8578, "Vcl.Controls.pas" + 5) + 
[5005A36C]{rtl280.bpl  } System.@GetMem (Line 4928, "System.pas" + 20) + [=11=]
[50061FB2]{rtl280.bpl  } System.@NewUnicodeString (Line 25652, "System.pas" + 10) + [=11=]
[5006245D]{rtl280.bpl  } System.@UStrAsg (Line 26576, "System.pas" + 19) + [=11=]
[50CCC54F]{vcl280.bpl  } Vcl.Controls.TWinControl.IsControlMouseMsg (Line 10330, "Vcl.Controls.pas" + 1) + 
[50CC985F]{vcl280.bpl  } Vcl.Controls.TControl.IsCustomStyleActive (Line 8592, "Vcl.Controls.pas" + 8) + 
[50CCCDBD]{vcl280.bpl  } Vcl.Controls.TWinControl.WndProc (Line 10579, "Vcl.Controls.pas" + 170) + 
[50CF0068]{vcl280.bpl  } Vcl.StdCtrls.TButtonControl.WndProc (Line 5708, "Vcl.StdCtrls.pas" + 13) + 
[50CCC338]{vcl280.bpl  } Vcl.Controls.TWinControl.MainWndProc (Line 10267, "Vcl.Controls.pas" + 3) + 
[50174200]{rtl280.bpl  } System.Classes.StdWndProc (Line 18318, "System.Classes.pas" + 8) + [=11=]
[50E0D68F]{vcl280.bpl  } Vcl.Forms.TApplication.ProcessMessage (Line 11317, "Vcl.Forms.pas" + 23) + 
[50E0D6D2]{vcl280.bpl  } Vcl.Forms.TApplication.HandleMessage (Line 11347, "Vcl.Forms.pas" + 1) + 
[50E089D2]{vcl280.bpl  } Vcl.Forms.TCustomForm.ShowModal (Line 7972, "Vcl.Forms.pas" + 50) + 
[50E08B78]{vcl280.bpl  } Vcl.Forms.TCustomForm.ShowModal (Line 8004, "Vcl.Forms.pas" + 82) + 
[20804954]{coreide280.bpl} Wizard.TWizard.Show (Line 1178, "Wizard.pas" + 18) + 
[51F020B0]{comcore280.bpl} ImportComponentWizard.CreateImportComponent (Line 331, "ImportComponentWizard.pas" + 15) + 
[51F08718]{comcore280.bpl} ComStdReg.TComMenus.DoImportComponentExecute (Line 118, "ComStdReg.pas" + 0) + 
[501733CF]{rtl280.bpl  } System.Classes.TBasicAction.Execute (Line 17813, "System.Classes.pas" + 3) + 
[50CAF9B2]{vcl280.bpl  } Vcl.ActnList.TCustomAction.Execute (Line 284, "Vcl.ActnList.pas" + 19) + 
[50173223]{rtl280.bpl  } System.Classes.TBasicActionLink.Execute (Line 17724, "System.Classes.pas" + 2) + 
[217C663D]{vclactnband280.bpl} Vcl.ActnMenus.TCustomActionMenuBar.ExecAction (Line 1099, "Vcl.ActnMenus.pas" + 6) + $D
[217C7EF8]{vclactnband280.bpl} Vcl.ActnMenus.TCustomActionMenuBar.TrackMenu (Line 1869, "Vcl.ActnMenus.pas" + 19) + 
[217CBA3E]{vclactnband280.bpl} Vcl.ActnMenus.TCustomActionMainMenuBar.TrackMenu (Line 3736, "Vcl.ActnMenus.pas" + 5) + 
[217C61BC]{vclactnband280.bpl} Vcl.ActnMenus.TCustomActionMenuBar.CMItemClicked (Line 969, "Vcl.ActnMenus.pas" + 2) + 
[217C61C5]{vclactnband280.bpl} Vcl.ActnMenus.TCustomActionMenuBar.CMItemClicked (Line 970, "Vcl.ActnMenus.pas" + 3) + 
[50CC7CCA]{vcl280.bpl  } Vcl.Controls.TControl.WndProc (Line 7544, "Vcl.Controls.pas" + 91) + 
[50CCCDBD]{vcl280.bpl  } Vcl.Controls.TWinControl.WndProc (Line 10579, "Vcl.Controls.pas" + 170) + 
[50CC7900]{vcl280.bpl  } Vcl.Controls.TControl.Perform (Line 7322, "Vcl.Controls.pas" + 10) + 
[50CCC435]{vcl280.bpl  } Vcl.Controls.GetControlAtPos (Line 10291, "Vcl.Controls.pas" + 2) + 
[50CCC506]{vcl280.bpl  } Vcl.Controls.InternalControlAtPos (Line 10315, "Vcl.Controls.pas" + 15) + $E
[50CCCC49]{vcl280.bpl  } Vcl.Controls.TWinControl.WndProc (Line 10527, "Vcl.Controls.pas" + 118) + D
[50CCCDBD]{vcl280.bpl  } Vcl.Controls.TWinControl.WndProc (Line 10579, "Vcl.Controls.pas" + 170) + 
[50060D74]{rtl280.bpl  } System.TMonitor.TryEnter (Line 19961, "System.pas" + 10) + [=11=]
[50060894]{rtl280.bpl  } System.TMonitor.Enter (Line 19622, "System.pas" + 4) + 
[500606FC]{rtl280.bpl  } System.TMonitor.CheckOwningThread (Line 19536, "System.pas" + 2) + [=11=]
[50060A22]{rtl280.bpl  } System.TMonitor.Exit (Line 19726, "System.pas" + 1) + 
[217C802B]{vclactnband280.bpl} Vcl.ActnMenus.TCustomActionMenuBar.WndProc (Line 1913, "Vcl.ActnMenus.pas" + 25) + 
[50CCC338]{vcl280.bpl  } Vcl.Controls.TWinControl.MainWndProc (Line 10267, "Vcl.Controls.pas" + 3) + 
[50174200]{rtl280.bpl  } System.Classes.StdWndProc (Line 18318, "System.Classes.pas" + 8) + [=11=]
[50E0D68F]{vcl280.bpl  } Vcl.Forms.TApplication.ProcessMessage (Line 11317, "Vcl.Forms.pas" + 23) + 
[50E0D6D2]{vcl280.bpl  } Vcl.Forms.TApplication.HandleMessage (Line 11347, "Vcl.Forms.pas" + 1) + 
[50E0DA11]{vcl280.bpl  } Vcl.Forms.TApplication.Run (Line 11486, "Vcl.Forms.pas" + 27) + 
[004F6F82]{bds.exe     } bds.bds (Line 227, "" + 16) + 

找到答案:

Delphi 无法添加 ActiveDS 注册。但是,您可以使用 tregsvr -t -c activeds.tlb 从命令提示符手动执行此操作。完成后,该库将出现在 Delphi 中的已注册类型库列表中,并且可以导入。