Results 1 to 4 of 4

Thread: I have a problem.

  1. #1

    I have a problem.

    System: Windows XP
    Compiler: Delphi 2005
    Libraries:

    Hi, can anyone help me ?

    I have 2 functions in a c++ dll and will them use from delphi.

    1. c++

    void DLL_Export SetWindowCaption( const wchar_t * wcptrtext)
    { setwindowcaption(wcptrtext);
    }

    delphi: procedure SetWindowCaption(const ca: pwidechar);cdecl;
    external dllname;
    SetWindowCaption('Test'); ---> this works

    2. c++

    void DLL_Export GetTexture(char * cptrFile)
    { return (void *) ....->gettexture(cptrFile);
    }

    delphi: function GetTexture(const name: pwidechar):texture;
    external dllname
    tex:=GetTexture('logo.bmp'); ------->DO NOT WORK
    the dll do not found the bitmap :roll:

    i think the transfer from 'name' is not ok .


    Sorry for my bad english.

  2. #2

    I have a problem.

    You should probably use the cdecl directive
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #3

    I have a problem.

    First... It's better to put your code between [ CODE ] or [ PASCAL ] tags. It makes your post more readable.

    Secondly.. why do you call your thread "I have a problem". I think that violates the "Help me" forum rules. You better use a name like "Cannot transfer a string to a C++ DLL" or something like that.

    Okay... your problem:

    I'm not a C++ hero, but i think Char* is the not a widechar pointer. You should try to define your function like this:

    [pascal]
    function GetTexture(const name: pChar):texture; cdecl; external dllname;
    [/pascal]

    Sometimes.. DLL's use STDCALL instead of CDECL but you should try CDECL first.

    Hope that helps
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4

    I have a problem.

    chronozphere ok.


    Boah....i have found the error. I have 'cdecl' forgotton in my function. :roll: ops:







    Sorry for my english

Bookmarks

Posting Permissions

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