有2个地方不明白的
1、在程序中注册COM组件时该怎么写程序
2、CreateOleObject(OleClass)OleClass是怎么定义的

解决方案 »

  1.   

    1》
    function RegisterOleFile (strOleFileName : STRING; OleAction : boolean ) : BOOLEAN;
    const
      RegisterOle = true;//×¢²á
      UnRegisterOle = false;//жÔØ
    type
      TOleRegisterFunction = function : HResult;//×¢²á»òжÔغ¯ÊýµÄÔ­ÐÍ
    var
      hLibraryHandle : THandle;//ÓÉLoadLibrary·µ»ØµÄDLL»òOCX¾ä±ú
      hFunctionAddress: TFarProc;//DLL»òOCXÖеĺ¯Êý¾ä±ú£¬ÓÉGetProcAddress·µ»Ø
      RegFunction : TOleRegisterFunction;//×¢²á»òжÔغ¯ÊýÖ¸Õë
    begin
      Result := FALSE;
      //´ò¿ªOLE/DCOMÎļþ£¬·µ»ØµÄDLL»òOCX¾ä±ú
      hLibraryHandle := LoadLibrary(PCHAR(strOleFileName));
      if (hLibraryHandle > 0) then//DLL»òOCX¾ä±úÕýÈ·
          try
            //·µ»Ø×¢²á»òжÔغ¯ÊýµÄÖ¸Õë
            if (OleAction = RegisterOle) then//·µ»Ø×¢²áº¯ÊýµÄÖ¸Õë
               hFunctionAddress := GetProcAddress(hLibraryHandle, pchar('DllRegisterServer'))
               else//·µ»ØжÔغ¯ÊýµÄÖ¸Õë
                   hFunctionAddress := GetProcAddress(hLibraryHandle, pchar('DllUnregisterServer'));
            if (hFunctionAddress <> NIL) then//×&cent;&sup2;á&raquo;ò&ETH;&para;&Ocirc;&Oslash;&ordm;&macr;&Ecirc;&yacute;&acute;&aelig;&Ocirc;&Uacute;
               begin
                 RegFunction := TOleRegisterFunction(hFunctionAddress);//&raquo;&ntilde;&Egrave;&iexcl;&sup2;&Ugrave;×÷&ordm;&macr;&Ecirc;&yacute;&micro;&Auml;&Ouml;&cedil;&Otilde;&euml;
                 if RegFunction >= 0 then //&Ouml;&acute;&ETH;&ETH;×&cent;&sup2;á&raquo;ò&ETH;&para;&Ocirc;&Oslash;&sup2;&Ugrave;×÷&pound;&not;·&micro;&raquo;&Oslash;&Ouml;&micro;>=0±í&Ecirc;&frac34;&Ouml;&acute;&ETH;&ETH;&sup3;&Eacute;&sup1;&brvbar;
                    result := true;
               end;
          finally
            FreeLibrary(hLibraryHandle);//&sup1;&Oslash;±&Otilde;&Ograve;&Ntilde;&acute;ò&iquest;&ordf;&micro;&Auml;OLE/DCOM&Icirc;&Auml;&frac14;&thorn;
          end;
    end;http://lysoft.7u7.net
      

  2.   

    这段程序我有的,但是用的时候好像在CreateOleOject(OleClassName)有问题OleClassName是怎么定义的
      

  3.   

    OleClassName是com组件的名称,一般具有xxx.xxx的形式
      

  4.   

    就是这里,对xxx.xxx,那么XXX是什么,我怎么不懂怎么回事,可否详细些,谢谢