Indigo Rose Software
Indigo Rose Software
Log in to the Customer Portal Customer Login
Software Development Discussion Forums Forums
+ Reply to Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2006
    Posts
    13

    dll function problem (please)

    Hello,

    I have a question about calling function DLLs and the SF7.
    Follow, i have a example function wich store in the variable test the value "shark"(string).

    Call of DLL function in the SF7.

    Local String arg1= "Select the computer server";
    Local String computerName= "0";

    DLLResult= DLL.CallFunction(compnet.dll, "NameOfComputerServer", "arg1,computerName", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

    Follow, i show you the source code of the DLL function.

    void NameOfComputerServer(char *msg,char *&test)
    {
    ShowMessage(msg);
    test= new char[6];
    strcpy(test,"Shark");
    ShowMessage(test);
    }

    Thatīs function return by reference one value for the variable test.
    I need get thatīs value.
    I canīt bring this value for to SF7. How am i make this????
    If do you have any example for this case please send me.

    Thank you!!

    Gustavo Pasqualini

  2. #2
    Join Date
    Jan 2000
    Posts
    2,002
    You cannot return values as string references. That is, string pointers are one-way (in). You could do the following instead:

    C code:

    Code:
    char szReturn[6];
    
    char* NameOfComputerServer(char *msg)
    {
    ShowMessage(msg);
    strcpy(szReturn,"Shark");
    ShowMessage(szReturn);
    return szReturn;
    }
    SUF code:

    Code:
    local larg1= "Select the computer server";
    local computerName= "0";
    
    DLLResult= DLL.CallFunction(compnet.dll, "NameOfComputerServer", "\""..larg1..",\""..computerName.."\"", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);

  3. #3
    Join Date
    Apr 2006
    Posts
    13

    Problem Dll Function (please)

    Follow, i show you my code in SF7.
    Itīs not work, an error appear...

    What is my mistake???

    local titu= "TITLE";
    local msg= "Select Server Name";
    local aguar= "Wait...";
    local String ComputerName= "0"

    DLLResult= DLL.CallFunction(SessionVar.Expand("%TempLaunchFol der%\\compnet.dll"), "_SelectServerName", "\""..titu..",\""..msg..",\""..aguar..",\""..Compu terName.."\"", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

  4. #4
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,936
    Code:
    DLLResult= DLL.CallFunction(SessionVar.Expand("%TempLaunchFol der%\\compnet.dll"), "_SelectServerName", "\""..titu.."\",\""..msg.."\",\""..aguar.."\",\""..Compu terName.."\"", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

  5. #5
    Join Date
    Jan 2000
    Posts
    2,002
    I think Worm hit it there. I was missing some quotes...

  6. #6
    Join Date
    Apr 2006
    Posts
    13
    We make an update in a function in our DLL, and remove the reference variable.
    Now, the DLL return the wanted value. We try to use that new DLL in a WISE Solution. In that software, the new DLL is running correctly.
    After we try to use the new DLL in your program it isn't running.
    I don't know what's happenning. Do you have a tip for us?
    The buy of a licence depends on that DLL running on our setup.

    Thank's a lot!

  7. #7
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,936
    Just looking at it again... change the return vallue to a string instead of a long.

  8. #8
    Join Date
    Apr 2006
    Posts
    13
    I have change the return value of that DLL to String and nothing...

    The DLL function itīs look like the fucntion below:

    char *NameOfComputerServer(char*arg1,char*arg2,char*arg 3)
    {
    char test[500];
    strcpy(test,"SHARK");
    return test;
    }

    The code in SF7:

    local String titu= "Audaces Vestuário";
    local String msg= "Escolha nome do micro servidor";
    local String aguar= "Aguarde...";
    local String te= "namePC";

    te= DLL.CallFunction(SessionVar.Expand("%TempLaunchFol der%\\CompNet.dll"), "_NameOfComputerServer", "\""..titu.."\",\""..msg.."\",\""..aguar.."\"" , DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

    Dialog.Message("TITLE",te,MB_OK);

  9. #9
    Join Date
    Apr 2006
    Posts
    13
    The Return Of That Dll Is A String Value...

  10. #10
    Join Date
    Jan 2000
    Posts
    2,002
    Have you tried changing DLL_CALL_STDCALL to DLL_CALL_CDECL? Also, try returning a global char* instead of the local one. The local one probably goes out of scope right after it is returned:

    Code:
    char test[500];
    
    char *NameOfComputerServer(char*arg1,char*arg2,char*arg 3)
    {
    strcpy(test,"SHARK");
    return test;
    }
    Also, you are using "_NameOfComputerServer" instead of "NameOfComputerServer" as the function name. Why is that? Try compiling the DLL in such a way that it does not decorate the function names.

    Read this article for an example of how to make a compatible DLL:

    How to Create a Simple Win32 DLL
    Last edited by Brett; 05-04-2006 at 08:04 AM.

  11. #11
    Join Date
    Apr 2006
    Posts
    13
    Hello,

    I will explain how the fuctions work.
    We have a function wich return the name of the computer and other wich show one window, where the user selects one name of the network computers .

    The first function works more or less then:

    char *returnNamePC()
    {
    char namePC[500];
    //take the name of the PC
    strcpy(namePC,GetLocalNamePC());

    return namePC;
    }
    This function donīt have parameters and work correctly in the SF7.

    The another function, have tree parameters:

    char *nameOfComputerServer(char *titleScreen,char *msg1,char *msg2)
    {
    char namePC[500];
    //call the screen for the user select the server name
    strcpy(namePC,ChooseNameOfPC(titleScreen,msg1,msg2 ));

    return namePC;
    }

    The functions works of the same form, but when i call the first function (in SF7), anything is ok. But when i call the second fuction the return (in SF7) is zero.
    We make a test, with a new fuction without parameters:

    char *nameOfComputerServer()
    {
    char namePC[500];

    //call the screen for the user select the server name
    strcpy(namePC,ChooseNameOfPC("titleScreen","msg1", "msg2"));

    return namePC;
    }

    This new fuction returns 0 too. Can you do explain me why???
    Apparently all is correct.

    Thank's...

Similar Threads

  1. Call Dll Function 2 - The Return
    By gustavoAUDACES in forum Setup Factory 7.0
    Replies: 2
    Last Post: 04-19-2006, 12:10 PM
  2. Another tough one... Interaction between Web and AMS
    By Agent Jones in forum AutoPlay Media Studio 5.0
    Replies: 13
    Last Post: 08-18-2005, 02:10 PM
  3. Calling DLL problem
    By Willis in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 05-11-2004, 03:57 PM
  4. Failed to call DLL function. (#2, Line 1)
    By fe4ther in forum Setup Factory 6.0
    Replies: 4
    Last Post: 01-14-2003, 08:01 PM

Posting Permissions

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