1 頁 (共 1 頁)

[轉貼]使用程式方法進行 ocx 的元件註冊

發表於 : 2008年 11月 28日, 12:26
tim
使用程式方法進行 ocx 的元件註冊!!


http://www.swissdelphicenter.ch/en/showcode.php?id=1281
http://delphi.ktop.com.tw/topic.asp?met ... berID=8041

代碼: 選擇全部

     
    type  
      TDllRegisterServer = function: HResult; stdcall;  
     
    function RegisterOCX(FileName: string): Boolean;  
    var  
      OCXHand: THandle;  
      RegFunc: TDllRegisterServer;  
    begin  
      OCXHand := LoadLibrary(PChar(FileName));  
      RegFunc := GetProcAddress(OCXHand, 'DllRegisterServer');  
      if @RegFunc <> nil then  
        Result := RegFunc = S_OK  
      else  
        Result := False;  
      FreeLibrary(OCXHand);  
    end;  
     
    function UnRegisterOCX(FileName: string): Boolean;  
    var  
      OCXHand: THandle;  
      RegFunc: TDllRegisterServer;  
    begin  
      OCXHand := LoadLibrary(PChar(FileName));  
      RegFunc := GetProcAddress(OCXHand, 'DllUnregisterServer');  
      if @RegFunc <> nil then  
        Result := RegFunc = S_OK  
      else  
        Result := False;  
      FreeLibrary(OCXHand);  
    end;