[HELP] PHP + DELPHI + COM
20/05/2015
0
Fala Galeraw.
Beleza?
Então estou com o seguinte problema, estou precisando ler uma DLL no php.
Tem um exemplo no site do PHP. E funciona perfeitamente para ler arquivos do Word. Porém quando meu colega aqui que manja de Delphi faz essa DLL COM. E eu tento chamar, a seguinte mensagem é apresentada.
"Não há suporte para esta interface"
Se na chamada eu colocar um Nome Qualquer. O Seguinte erro é apresentado.
"Sintaxe inválida"
Então ao meu ver me parece que a chamada esta certa. Somente falta algo nessa DLL do Delphi para funcionar corretamente.
Segue Códigos:
PHP Code.
Delphi Code.
Alguém ai pode me ajudar?
Abraços.
Beleza?
Então estou com o seguinte problema, estou precisando ler uma DLL no php.
Tem um exemplo no site do PHP. E funciona perfeitamente para ler arquivos do Word. Porém quando meu colega aqui que manja de Delphi faz essa DLL COM. E eu tento chamar, a seguinte mensagem é apresentada.
"Não há suporte para esta interface"
Se na chamada eu colocar um Nome Qualquer. O Seguinte erro é apresentado.
"Sintaxe inválida"
Então ao meu ver me parece que a chamada esta certa. Somente falta algo nessa DLL do Delphi para funcionar corretamente.
Segue Códigos:
PHP Code.
try { $obj = new COM("{20B9C5D8-CA47-4FEC-BD75-1D6E676E346D}"); // or die ( "Unable to instantiate the COM!"); $result = $obj->RetornaOI( 1 ) ; echo $result; } catch (Exception $e) { echo 'Exception: ', $e->getMessage(), "\n"; }
Delphi Code.
unit Project1_TLB; {$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. {$WARN SYMBOL_PLATFORM OFF} {$WRITEABLECONST ON} {$VARPROPSETTER ON} {$ALIGN 4} interface uses Winapi.Windows, System.Classes, System.Variants, System.Win.StdVCL, Vcl.Graphics, Vcl.OleServer, Winapi.ActiveX; // *********************************************************************// // GUIDS declared in the TypeLibrary. Following prefixes are used: // Type Libraries : LIBID_xxxx // CoClasses : CLASS_xxxx // DISPInterfaces : DIID_xxxx // Non-DISP interfaces: IID_xxxx // *********************************************************************// const // TypeLibrary Major and minor versions Project1MajorVersion = 1; Project1MinorVersion = 0; LIBID_Project1: TGUID = '{3F1A5D47-8E64-4266-B0C5-8D30A6A2F15E}'; IID_ITesteOI: TGUID = '{A702E3FB-107E-4E8E-BFF2-539B7655D268}'; CLASS_TesteOI: TGUID = '{20B9C5D8-CA47-4FEC-BD75-1D6E676E346D}'; type // *********************************************************************// // Forward declaration of types defined in TypeLibrary // *********************************************************************// ITesteOI = interface; // *********************************************************************// // Declaration of CoClasses defined in Type Library // (NOTE: Here we map each CoClass to its Default Interface) // *********************************************************************// TesteOI = ITesteOI; // *********************************************************************// // Interface: ITesteOI // Flags: (256) OleAutomation // GUID: {A702E3FB-107E-4E8E-BFF2-539B7655D268} // *********************************************************************// ITesteOI = interface(IUnknown) ['{A702E3FB-107E-4E8E-BFF2-539B7655D268}'] function RetornaOI(Parametro: Integer): WideString; stdcall; end; // *********************************************************************// // The Class CoTesteOI provides a Create and CreateRemote method to // create instances of the default interface ITesteOI exposed by // the CoClass TesteOI. The functions are intended to be used by // clients wishing to automate the CoClass objects exposed by the // server of this typelibrary. // *********************************************************************// CoTesteOI = class class function Create: ITesteOI; class function CreateRemote(const MachineName: string): ITesteOI; end; implementation uses System.Win.ComObj; class function CoTesteOI.Create: ITesteOI; begin Result := CreateComObject(CLASS_TesteOI) as ITesteOI; end; class function CoTesteOI.CreateRemote(const MachineName: string): ITesteOI; begin Result := CreateRemoteComObject(MachineName, CLASS_TesteOI) as ITesteOI; end; end.
Alguém ai pode me ajudar?
Abraços.
Eduardo Martins
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)