Thread: problem in calling DLL

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    18

    problem in calling DLL

    Hello every body !

    Few days back I have posted a problem regarding static variables in structure.

    I have got solution for that problem.

    But now I have new problem related to that.

    It is as follow:

    I am sending parameters from main CPP file to DLL cpp file.

    But in DLL I am not able to get these parameters...

    the code is as follow:

    DLL file:

    code:
    Code:
    	
    
    //This is dll header file where structure is define
    
    //dll.h
    
    typedef struct{
       static char szOriginalAddress[0x100];
       static char szRecipientAddress[0x100];
      static char szFileName[0x100];
    }TExternalFilter;
    
    EXPORT DWORD MerakFilterProc(TExternalFilter*);
    
    //This is dll.cpp
    
    #include "dll.h"
    
    BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved	 )
    {
        return TRUE;
    }
    
     char TExternalFilter::szOriginalAddress[0x100];
     char TExternalFilter::szRecipientAddress[0x100];
     char TExternalFilter::szFileName[0x100];
    
    EXPORT DWORD MerakFilterProc(TExternalFilter*)
    {		
    	 char temp1[256];
    	std:: string temp1;
     
      strcpy(temp1,TExternalFilter::szOriginalAddress);
      strcpy(temp2,TExternalFilter::szRecipientAddress);
     strcpy(temp3,TExternalFilter::szFileName);
    }
    // I am not to fetch values here
    Now this DLL is called by main CPP program which is as follow:

    Code:
    int main(int argc, char* argv[])
    {	
    TExternalFilter ExternalFilter={"[email protected]","[email protected]","sdfsd"};	
    
    
    	ch = MerakFilterProc(&ExternalFilter);	
    	
    }
    //This program call DLL and value return by DLL is recieved in ch
    //but this is not working
    Onething I want to clear that when I used char in place of static char then no

    problem there,but I need solution with static char only.

    so please help me..

    Thanks
    Bhagwat

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Code:
    char temp1[256]
    std:: string temp1;
    Using the same name for two different variables will not help yor case.

    Code:
    typedef struct{
       static char szOriginalAddress[0x100];
       static char szRecipientAddress[0x100];
      static char szFileName[0x100];
    }TExternalFilter;
    Why exactly do they need to be static? You are complicating your code and I can't see any advantage to it (is the static thing a requirement?).

    Code:
    TExternalFilter ExternalFilter={"[email protected]","[email protected]","sdfsd"};
    I've never seen this type of initialization before. But then and again I'm new. However, You cannot really do this. Your struct object has no members. your struct class, on the ther hand has three static members.

    You can, on the other hand, define a constructor that will take three parameters and use these to assign to the static members.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    18

    Reply to your question

    Hi marof!

    I will like to remove your doubt.

    marof, I am developing a application in VC++ for mail server.

    In this we have to put the member of structure as static.

    Now the mail server call this DLL and member are pass as parameter.

    I am facing the problem that as these member are static and when I pass these member

    are passed to DLL they are initilize to nothing in DLL an value are lost.

    I just want that to known that I how can I reterive values of without changing DLL

    structure.

    One thing I want to say that I can't change the DLL structure.


    If you have any solutiom then please reply.

    Thanks
    Bhagwat

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Delphi DLL Problem, C++ hates Delphi strings
    By Cogman in forum C++ Programming
    Replies: 5
    Last Post: 09-08-2008, 07:32 PM
  2. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  3. Templates from DLL or static library problem
    By mikahell in forum C++ Programming
    Replies: 2
    Last Post: 01-01-2008, 01:49 AM
  4. Calling a VB DLL w/ forms from C++ DLL
    By UW_COOP in forum C++ Programming
    Replies: 8
    Last Post: 06-30-2003, 08:04 AM
  5. VCL and DLL class problem
    By borland_man in forum C++ Programming
    Replies: 1
    Last Post: 02-13-2002, 11:07 AM