線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:916
推到 Plurk!
推到 Facebook!

Delphi中聲明如何轉成C++的聲明

尚未結案
sunnycoco99
一般會員


發表:2
回覆:3
積分:1
註冊:2004-11-16

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-11-23 10:42:57 IP:219.147.xxx.xxx 未訂閱
請教如下在Delphi中的聲明如何轉成C 的聲明呢 type IMLangConvertCharset = interface ['{D66D6F98-CDAA-11D0-B822-00C04FC9B31F}']
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-12-01 21:25:00 IP:211.76.xxx.xxx 未訂閱
因為您沒有給完整的宣告,所以我無法試... 後來在網路上找到(可能是完整的)Source http://www.lihuasoft.net/article/show.php?id=227    我把以下存成 uCodePageConverter.pas
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Unit Name : uCodePageConverter
* Autor   : Daniel Wischnewski
* Copyright : Copyright c  2002 by gate(n)etwork. All Right Reserved.
* Urheber  : Daniel Wischnewski
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
unit uCodePageConverter;    interface    uses
 Windows;    const
 IID_MLangConvertCharset: TGUID = '{D66D6F98-CDAA-11D0-B822-00C04FC9B31F}';
 CLASS_MLangConvertCharset :TGUID = '{D66D6F99-CDAA-11D0-B822-00C04FC9B31F}';    type
 tagMLCONVCHARF = DWORD;    const
 MLCONVCHARF_AUTODETECT: tagMLCONVCHARF = 1;
 MLCONVCHARF_ENTITIZE : tagMLCONVCHARF = 2;    type
 tagCODEPAGE = UINT;    const
 CODEPAGE_Thai         : tagCODEPAGE = 0874;
 CODEPAGE_Japanese       : tagCODEPAGE = 0932;
 CODEPAGE_Chinese_PRC      : tagCODEPAGE = 0936;
 CODEPAGE_Korean        : tagCODEPAGE = 0949;
 CODEPAGE_Chinese_Taiwan    : tagCODEPAGE = 0950;
 CODEPAGE_UniCode        : tagCODEPAGE = 1200;
 CODEPAGE_Windows_31_EastEurope : tagCODEPAGE = 1250;
 CODEPAGE_Windows_31_Cyrillic  : tagCODEPAGE = 1251;
 CODEPAGE_Windows_31_Latin1   : tagCODEPAGE = 1252;
 CODEPAGE_Windows_31_Greek   : tagCODEPAGE = 1253;
 CODEPAGE_Windows_31_Turkish  : tagCODEPAGE = 1254;
 CODEPAGE_Hebrew        : tagCODEPAGE = 1255;
 CODEPAGE_Arabic        : tagCODEPAGE = 1256;
 CODEPAGE_Baltic        : tagCODEPAGE = 1257;    type
 IMLangConvertCharset = interface
  ['{D66D6F98-CDAA-11D0-B822-00C04FC9B31F}']
  function Initialize(
   uiSrcCodePage: tagCODEPAGE; uiDstCodePage: tagCODEPAGE;
   dwProperty: tagMLCONVCHARF
  ): HResult; stdcall;
  function GetSourceCodePage(
   out puiSrcCodePage: tagCODEPAGE
  ): HResult; stdcall;
  function GetDestinationCodePage(
   out puiDstCodePage: tagCODEPAGE
  ): HResult; stdcall;
  function GetProperty(out pdwProperty: tagMLCONVCHARF): HResult; stdcall;
  function DoConversion(
   pSrcStr: PChar; pcSrcSize: PUINT; pDstStr: PChar; pcDstSize: PUINT
  ): HResult; stdcall;
  function DoConversionToUnicode(
   pSrcStr: PChar; pcSrcSize: PUINT; pDstStr: PWChar; pcDstSize: PUINT
  ): HResult; stdcall;
  function DoConversionFromUnicode(
   pSrcStr: PWChar; pcSrcSize: PUINT; pDstStr: PChar; pcDstSize: PUINT
  ): HResult; stdcall;
 end;     CoMLangConvertCharset = class
  class function Create: IMLangConvertCharset;
  class function CreateRemote(const MachineName: string): IMLangConvertCharset;
 end;    implementation    uses
 ComObj;    { CoMLangConvertCharset }    class function CoMLangConvertCharset.Create: IMLangConvertCharset;
begin
 Result := CreateComObject(CLASS_MLangConvertCharset) as IMLangConvertCharset;
end;    class function CoMLangConvertCharset.CreateRemote(
 const MachineName: string
): IMLangConvertCharset;
begin
 Result := CreateRemoteComObject(
  MachineName, CLASS_MLangConvertCharset
 ) as IMLangConvertCharset;
end;    end.
直接加入任一個 BCB 的專案中,直接按 build, BCB 就會幫我們轉換,得到 uCodePageConverter.hpp
// Borland C   Builder
// Copyright (c) 1995, 1999 by Borland International
// All rights reserved    // (DO NOT EDIT: machine generated header) 'uCodePageConverter.pas' rev: 5.00    #ifndef uCodePageConverterHPP
#define uCodePageConverterHPP    #pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include  // Pascal unit
#include  // Pascal unit
#include  // Pascal unit    //-- user supplied -----------------------------------------------------------    namespace Ucodepageconverter
{
//-- type declarations -------------------------------------------------------
typedef unsigned tagMLCONVCHARF;    typedef unsigned tagCODEPAGE;    __interface IMLangConvertCharset;
typedef System::DelphiInterface _di_IMLangConvertCharset;
__interface INTERFACE_UUID("{D66D6F98-CDAA-11D0-B822-00C04FC9B31F}") IMLangConvertCharset  : public IUnknown 
 
{
 
public:
 virtual HRESULT __stdcall Initialize(unsigned uiSrcCodePage, unsigned uiDstCodePage, unsigned dwProperty
  ) = 0 ;
 virtual HRESULT __stdcall GetSourceCodePage(/* out */ unsigned &puiSrcCodePage) = 0 ;
 virtual HRESULT __stdcall GetDestinationCodePage(/* out */ unsigned &puiDstCodePage) = 0 ;
 virtual HRESULT __stdcall GetProperty(/* out */ unsigned &pdwProperty) = 0 ;
 virtual HRESULT __stdcall DoConversion(char * pSrcStr, PUINT pcSrcSize, char * pDstStr, PUINT pcDstSize
  ) = 0 ;
 virtual HRESULT __stdcall DoConversionToUnicode(char * pSrcStr, PUINT pcSrcSize, wchar_t * pDstStr, 
  PUINT pcDstSize) = 0 ;
 virtual HRESULT __stdcall DoConversionFromUnicode(wchar_t * pSrcStr, PUINT pcSrcSize, char * pDstStr
  , PUINT pcDstSize) = 0 ;
};    class DELPHICLASS CoMLangConvertCharset;
class PASCALIMPLEMENTATION CoMLangConvertCharset : public System::TObject 
{
 typedef System::TObject inherited;
 
public:
 /*         class method */ static _di_IMLangConvertCharset __fastcall Create(TMetaClass* vmt);
 /*         class method */ static _di_IMLangConvertCharset __fastcall CreateRemote(TMetaClass* vmt, 
  const AnsiString MachineName);
public:
 #pragma option push -w-inl
 /* TObject.Create */ inline __fastcall CoMLangConvertCharset(void) : System::TObject() { }
 #pragma option pop
 #pragma option push -w-inl
 /* TObject.Destroy */ inline __fastcall virtual ~CoMLangConvertCharset(void) { }
 #pragma option pop
 
};    //-- var, const, procedure ---------------------------------------------------
extern PACKAGE GUID IID_MLangConvertCharset;
extern PACKAGE GUID CLASS_MLangConvertCharset;
extern PACKAGE unsigned MLCONVCHARF_AUTODETECT;
extern PACKAGE unsigned MLCONVCHARF_ENTITIZE;
extern PACKAGE unsigned CODEPAGE_Thai;
extern PACKAGE unsigned CODEPAGE_Japanese;
extern PACKAGE unsigned CODEPAGE_Chinese_PRC;
extern PACKAGE unsigned CODEPAGE_Korean;
extern PACKAGE unsigned CODEPAGE_Chinese_Taiwan;
extern PACKAGE unsigned CODEPAGE_UniCode;
extern PACKAGE unsigned CODEPAGE_Windows_31_EastEurope;
extern PACKAGE unsigned CODEPAGE_Windows_31_Cyrillic;
extern PACKAGE unsigned CODEPAGE_Windows_31_Latin1;
extern PACKAGE unsigned CODEPAGE_Windows_31_Greek;
extern PACKAGE unsigned CODEPAGE_Windows_31_Turkish;
extern PACKAGE unsigned CODEPAGE_Hebrew;
extern PACKAGE unsigned CODEPAGE_Arabic;
extern PACKAGE unsigned CODEPAGE_Baltic;    } /* namespace Ucodepageconverter */
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace Ucodepageconverter;
#endif
#pragma option pop // -w-
#pragma option pop // -Vx    #pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif // uCodePageConverter
接著就可以在需要用它的 Unit.cpp 中去
#include "uCodePageConverter.hpp"
吃軟也吃硬 dllee.ktop.com.tw StatPlus 系統資源監測器 @ KTOP VMASK - ViewMove Automation Software Kernel
------
http://www.ViewMove.com
sunnycoco99
一般會員


發表:2
回覆:3
積分:1
註冊:2004-11-16

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-12-07 14:39:43 IP:219.147.xxx.xxx 未訂閱
感謝dllee大大,這個直接轉果然非常有效 學到方法了
系統時間:2024-11-23 20:05:55
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!