problem with a parameter of a function in a DLL. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

problem with a parameter of a function in a DLL.

Juan_jose.Juan_jose. Posts: 24Member
Hello

I've developed a DLL in delphi, and one of the functions requires a Pointer...

Supossing the Function is AAA()

y tryed doing the next:

int a;
int *a2;

a2 = &a;

AAA(a2);


but it doesn't work, how can i do it??????


I hope you can help me


>juan<

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    [b][red]This message was edited by stober at 2006-3-23 21:5:45[/red][/b][hr]
    : Hello
    :
    : I've developed a DLL in delphi, and one of the functions requires a Pointer...
    :
    : Supossing the Function is AAA()
    :
    : y tryed doing the next:
    :
    : int a;
    : int *a2;
    :
    : a2 = &a;
    :
    : AAA(a2);
    :
    :
    : but it doesn't work, how can i do it??????
    :
    :
    : I hope you can help me
    :
    :
    : >juan<
    :



    how to do in C/C++ it depends on how the function is prototyped.
    [code]
    // function prototype
    void AAA(int* ptr);

    int a;
    // now pass a pointer to function AAA
    // its not necessary to use another variable
    AAA(&a);
    [/code]

    beyond that, I have no clue how to call delphi functions from c, or even if they can be called from c.

    When you say "it doesn't work" just what exactly do you mean? is it a compile-time or runtime error? what was the error or behavior?

    Maybe (just guessing here) delphi uses the __pascal calling convention? then you need to prototype the function like this

    void __pascal AAA(int* ptr);





  • Juan_jose.Juan_jose. Posts: 24Member
    Hi!!!

    ok first of all, thank you for answering!!!.
    i could slove the probleamm like this:

    The function is prototyped: AAA(char *buf)

    and then i declare an array:

    char ScreenVAR[800*600*2];
    char *ScreenP;

    ScreenP = &ScreenVAR;

    AAA(ScreenP);

    ===============================
    i'm a begginer in C, and i was trying to rewrite my code to it...
    in pascal a pointer variable, is like a matrix of bytes... not just a variable pointing to another (but it can be done)

    C IS THE GREATEST OF THE GIGH LEVEL LANGUAGE

    It gives you more freedom!


    Thanke you.

    Juan
  • LundinLundin Posts: 3,711Member
    : [b][red]This message was edited by stober at 2006-3-23 21:5:45[/red][/b][hr]
    : : Hello
    : :
    : : I've developed a DLL in delphi, and one of the functions requires a Pointer...
    : :
    : : Supossing the Function is AAA()
    : :
    : : y tryed doing the next:
    : :
    : : int a;
    : : int *a2;
    : :
    : : a2 = &a;
    : :
    : : AAA(a2);
    : :
    : :
    : : but it doesn't work, how can i do it??????
    : :
    : :
    : : I hope you can help me
    : :
    : :
    : : >juan<
    : :
    :
    :
    :
    : how to do in C/C++ it depends on how the function is prototyped.
    : [code]
    : // function prototype
    : void AAA(int* ptr);
    :
    : int a;
    : // now pass a pointer to function AAA
    : // its not necessary to use another variable
    : AAA(&a);
    : [/code]
    :
    : beyond that, I have no clue how to call delphi functions from c, or even if they can be called from c.
    :
    : When you say "it doesn't work" just what exactly do you mean? is it a compile-time or runtime error? what was the error or behavior?
    :
    : Maybe (just guessing here) delphi uses the __pascal calling convention? then you need to prototype the function like this
    :
    : void __pascal AAA(int* ptr);
    :


    I think __pascal is something VC++ specific. The PASCAL calling convention from the win api should be used.

    void PASCAL AAA(int* ptr);

    But PASCAL is probably defined as __stdcall, iirc...
  • stoberstober Posts: 9,765Member ✭✭✭
    :
    :
    : I think __pascal is something VC++ specific. The PASCAL calling convention from the win api should be used.
    :
    : void PASCAL AAA(int* ptr);
    :
    : But PASCAL is probably defined as __stdcall, iirc...
    :


    its deprecated in VC++ 2005.
  • stoberstober Posts: 9,765Member ✭✭✭
    : Hi!!!
    :
    : ok first of all, thank you for answering!!!.
    : i could slove the probleamm like this:
    :
    : The function is prototyped: AAA(char *buf)
    :
    : and then i declare an array:
    :
    : char ScreenVAR[800*600*2];
    : char *ScreenP;
    :
    : ScreenP = &ScreenVAR;
    :
    : AAA(ScreenP);
    :
    [blue]it is not necessary to create another variable, all arrays are passed to functions as pointers[/blue]

    [code]
    char ScreenVAR[800*600*2];
    AAA(ScreenVAR);
    [/code]
Sign In or Register to comment.