header image

Ryuzeeについて

mixi Twitter Twitter

携帯対応

QRコード

RING

人気ブログランキング

新着記事

1月 2nd, 2009 Delphi none Comments

XML-RPCを使ってごにょごにょするためにDelphi5を使ってWindowsソフト作ろうとしていたんだよ。
#いまさらDelphi5なのは、さておき。

XML-RPCなんて自前で処理書くのバカバカしいから、コンポーネント探してみて、Delphi XML-RPCってのみつけて早速試してみたんだけど、コンパイル通らない・・・。調べてみたら、

IInterface

  • COMを使用しない場合のインターフェース
  • Delphi 6 で導入された

そういうことか。ということで、IInterfaceをIUnknownに書き換えて・・・以下のように修正

sourceフォルダにVariants.pasを作成する。中身は雛形の通りで良い。

unit Variants;

interface

implementation

end.

その他は3ファイル。BuildXmlRpcLib.dprとXmlRpcTypes.pasとXmlRpcServer.pasを下記のdiffの通り修正する。
基本的には、IInterfaceとIUnknownにすることと、StrToBoolがDelphi5には無いので適当に実装を追加するってことくらい。

Index: lib/dxmlrpc-2.0.0/build/BuildXmlRpcLib.dpr
===================================================================
--- lib/dxmlrpc-2.0.0/build/BuildXmlRpcLib.dpr (リビジョン 49)
+++ lib/dxmlrpc-2.0.0/build/BuildXmlRpcLib.dpr (リビジョン 50)
@@ -10,5 +10,6 @@
   XmlRpcTypes in '..sourceXmlRpcTypes.pas',
   XmlRpcCommon in '..sourceXmlRpcCommon.pas',
-  XmlRpcServer in '..sourceXmlRpcServer.pas';
+  XmlRpcServer in '..sourceXmlRpcServer.pas',
+  Variants in '..sourceVariants.pas';
 
 begin
Index: lib/dxmlrpc-2.0.0/source/XmlRpcTypes.pas
===================================================================
--- lib/dxmlrpc-2.0.0/source/XmlRpcTypes.pas (リビジョン 49)
+++ lib/dxmlrpc-2.0.0/source/XmlRpcTypes.pas (リビジョン 50)
@@ -36,5 +36,5 @@
 
 uses
-  SysUtils, Classes, Contnrs, DIMime, XmlRpcCommon;
+  SysUtils, Classes, Contnrs, DIMime, XmlRpcCommon, ActiveX, ComObj;
 
 type
@@ -45,5 +45,5 @@
       dtStruct, dtArray, dtError, dtNone, dtName, dtValue);
 
-  IRpcCustomItem = interface(IInterface)
+  IRpcCustomItem = interface(IUnknown)
   ['{3441C47B-364D-4BE6-834E-E05C4FCAE9A6}']
     function GetAsRawString: string;
@@ -196,5 +196,5 @@
   end;
 
-  IRpcCustomArray = interface(IInterface)
+  IRpcCustomArray = interface(IUnknown)
   ['{8177A796-7C3B-4C01-901C-88A13DA61F85}']
     function GetItems(Index: Integer): TRpcArrayItem;
@@ -259,5 +259,5 @@
   end;
 
-  IRpcStruct = interface(IInterface)
+  IRpcStruct = interface(IUnknown)
   ['{7527E27A-6B61-41D6-9546-93DC816D8285}']
     function InternalAddItem(const Key: string): TRpcStructItem;
@@ -372,5 +372,8 @@
   TRpcReturn = TRpcFunction;
 
+  function strtobool(value : string) : Boolean;
+
 implementation
+
 
 {
@@ -839,4 +842,17 @@
 end;
 
+function strToBool(value : String) : Boolean;
+begin
+  if lowercase(value) = 'true' then
+  begin
+    result := true; exit;
+  end;
+  if strtointdef(value, 0) = 1 then
+  begin
+    result := true;
+    exit;
+  end;
+  result := false;
+end;
 
 {
Index: lib/dxmlrpc-2.0.0/source/XmlRpcServer.pas
===================================================================
--- lib/dxmlrpc-2.0.0/source/XmlRpcServer.pas (リビジョン 49)
+++ lib/dxmlrpc-2.0.0/source/XmlRpcServer.pas (リビジョン 50)
@@ -335,5 +335,5 @@
   // FMethodList := TList.Create; Take TObjectList instead of TList;
   FMethodList := TObjectList.Create;
-  FMethodList.OwnsObjects := True;
+  //FMethodList.OwnsObjects := True;
   FLock := TCriticalSection.Create;
 end;

これで動作するようになった。

“[どうでもよいこと]Delphi5でXML-RPC(力技)”へのコメントはありません。

コメントはありません。是非コメントしてください。

コメントする

XHTML: 以下のタグが利用可能です: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback

 


ads

読まなきゃモグリ