+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Interfacing the API in Delphi XE

  1. #1
    Licensed User johngb's Avatar
    Join Date
    Oct 2003
    Location
    Surrey, UK
    Posts
    1,340

    Default Interfacing the API in Delphi XE

    Has anyone tried to use the Plugin API with Delphi XE.

    Up until now I have been happily working wih Ansi strings and Chars in Delphi 2007, however, as Delphi XE is now Unicode based all my Chars are WideStrings and David B's Plugin examples do not compile.

    e.g. (This is my code not davids but the point is the same....)

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




    Function TideInterface.GetIDEPath():String;
    Var
    Buffer: Array of Char

    Begin
    If plgIsConnected then
    begin
    SetLength(Buffer, 256);
    plgGetPathIDE(PChar(Buffer),256);
    Result := PChar(Buffer);
    end;
    Buffer := Nil;
    end;

    I tried converting to AnsiChar and PAnsiChar and although it got through with warnings - e.g. Suspicious type canse to PAnsiChar. mcplugInMgr.dll reported Access violation when I tried to run it under the IDE.


    So how now do I send and receice asci strings through the API in XE?
    Last edited by johngb; 1st July 2011 at 19:40.
    JohnB


  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2
    Licensed User DaveS's Avatar
    Join Date
    Aug 2004
    Location
    North Yorkshire
    Posts
    649


    Default Re: Interfacing the API in Delphi XE

    Hi John

    Yes, have been using Delphi 2009 + XE for plugins for some time now.
    You will always get the Delphi compiler warnings, Suspicious type cask to PAnsiChar

    function ideGetPathIDE() : String;
    var
    xBuffer: array[0..256] of AnsiChar;
    begin
    plgGetPathIDE(xBuffer,256);
    result := string(xBuffer);
    end;
    Regards
    Dave

  4. #3
    Licensed User johngb's Avatar
    Join Date
    Oct 2003
    Location
    Surrey, UK
    Posts
    1,340


    Default Re: Interfacing the API in Delphi XE

    So I don't need to worry about the suspicious type casts messages.

    This doesnt work on my machine - it error with incompatible types Array of AnsiChar and Pointer.
    The plgGetPathIDE is expecting a pointer. xBuffer is an Array

    Also, this used to work in D2007

    Procedure TIdeInterface.PasteTextAt(Text: String; Position: Cursor);
    // Places the text at the insertion point specified by Cursor.
    Begin
    If plgIsConnected Then
    plgSetPageTextAt (Position.CsrX, Position.CsrY, PChar(Text));
    end;

    If I change PChar to PAnsiCHar it compiles OK but doesn't work in XE.
    Last edited by johngb; 2nd July 2011 at 09:46.
    JohnB

  5. #4
    Licensed User DaveS's Avatar
    Join Date
    Aug 2004
    Location
    North Yorkshire
    Posts
    649


    Default Re: Interfacing the API in Delphi XE

    I will dig out some code and do some tests, I haven't checked it on Win7 64 bit yet, is that your operating system.
    Regards
    Dave

  6. #5
    Licensed User johngb's Avatar
    Join Date
    Oct 2003
    Location
    Surrey, UK
    Posts
    1,340


    Default Re: Interfacing the API in Delphi XE

    Yes

    I assume I am right in understanding that LPSTR is a long pointer to a string which is in practice an array of ??Char, AnsiChar??
    So all strings passed between the mcPlugInMgr and a Plugin must be pointers.

    It seems to me that the AnsiChar type is not liked by the mcPlugInMgr
    JohnB

  7. #6
    Licensed User DaveS's Avatar
    Join Date
    Aug 2004
    Location
    North Yorkshire
    Posts
    649


    Default Re: Interfacing the API in Delphi XE

    The message invalid pointer may be because it can't locate the dll or entry point.
    Do other plugins work?
    Is the mcPluginMgr.dll installed to C:\Windows\SysWOW64\ <-32 bit dlls location
    Is the ProtonIDE\ProtonIDE.exe installed to C:\Program Files (x86)\ <-32 bit exe's location
    EUSART_Calc was compiled in Delphi XE, have attached files used for the mcPluginMgr its rough and ready, if I get time I will build a test app for all functions, I never got around to doing the full interface or did I?

    cPlugin.zip
    Regards
    Dave

  8. #7
    Licensed User DaveS's Avatar
    Join Date
    Aug 2004
    Location
    North Yorkshire
    Posts
    649


    Default Re: Interfacing the API in Delphi XE

    Hi John
    Welcome to the unicode world.
    Quote Originally Posted by johngb View Post
    So I don't need to worry about the suspicious type casts messages
    It's not ideal and it is possible it won't convert an ansistring to unicode, but should be no problem with ansi latin chars.
    Could do with a dll that was unicode or better could handle ansi and unicode.

    A few quick notes that might help.
    A Char in Delphi 2007 and versions before is an System.AnsiChar and a string is an System.ansistring.
    In Delphi 2009 and versions after a char is a System.Char and a string is an System.string.
    An AnsiChar is one byte in size.
    A Char(Unicode) is two bytes in size.
    So it's important we allocate the correct memory size.
    LPSTR is a System.PAnsiChar

    Next building 64 bit plugins (Can't do, we need a 64 bit dll)
    Regards
    Dave

  9. #8
    Licensed User johngb's Avatar
    Join Date
    Oct 2003
    Location
    Surrey, UK
    Posts
    1,340


    Default Re: Interfacing the API in Delphi XE

    Thought I had sent this but cannot see it in the thread....

    Installed PIC Fuse Configurator Mk 2 successsfully and it runs fine so I think the PDS istallation is basically OK
    PIC FuseConfigurator Mk2 was compiled in D2007.

    Also got a minor problem with XE in that when I close it I get an Access violation in rtl150.bpl. Also the structure panel is blank when I view code but not when I view design. Tried uninstalling and reinstalling a couple of times but no better.
    JohnB

  10. #9
    Licensed User DaveS's Avatar
    Join Date
    Aug 2004
    Location
    North Yorkshire
    Posts
    649


    Default Re: Interfacing the API in Delphi XE

    Quote Originally Posted by johngb View Post
    Also got a minor problem with XE in that when I close it I get an Access violation in rtl150.bpl. Also the structure panel is blank when I view code but not when I view design. Tried uninstalling and reinstalling a couple of times but no better.
    Don't know if this will help, any version of Delphi set it up so it runs as administrator, I read this somewhere.
    Have you installed Update Pack 1 for Delphi XE and C++Builder XE

    I haven't got Delphi XE installed on Win7 64 bit, can't say anymore because of NDA, so I can not test this.
    Last edited by DaveS; 2nd July 2011 at 13:08. Reason: added to
    Regards
    Dave

  11. #10
    Licensed User johngb's Avatar
    Join Date
    Oct 2003
    Location
    Surrey, UK
    Posts
    1,340


    Default Re: Interfacing the API in Delphi XE

    The update pack didnt help - all sme symptoms still there.
    Have posted a query on one of the Delphi Forums
    JohnB

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. New Starter Edition of Delphi
    By normnet in forum The Lounge
    Replies: 11
    Last Post: 5th February 2011, 00:06
  2. Delphi help
    By Richard in forum The Lounge
    Replies: 2
    Last Post: 20th April 2007, 09:16
  3. Delphi Serial
    By See_Mos in forum The Lounge
    Replies: 15
    Last Post: 19th January 2007, 08:49
  4. Serial Comms for Delphi
    By C_Moore in forum The Lounge
    Replies: 10
    Last Post: 28th June 2006, 23:12
  5. Easy HID Delphi
    By Richard in forum The Lounge
    Replies: 6
    Last Post: 25th June 2006, 20:56

Members who have read this thread since 6th May 2012, 10:51 : 0

Actions :  (Set Date)  (Clear Date)

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts