Click here to Skip to main content
15,921,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC Toolbox Pin
Maximilien1-Apr-05 2:50
Maximilien1-Apr-05 2:50 
GeneralRe: MFC Toolbox Pin
charu1233-Apr-05 17:19
charu1233-Apr-05 17:19 
GeneralAccess File Copy Pin
Halberad1-Apr-05 0:51
Halberad1-Apr-05 0:51 
GeneralRe: Access File Copy Pin
Alexander M.,1-Apr-05 2:57
Alexander M.,1-Apr-05 2:57 
GeneralRe: Access File Copy Pin
Halberad1-Apr-05 3:12
Halberad1-Apr-05 3:12 
GeneralRe: Access File Copy Pin
David Crow1-Apr-05 4:01
David Crow1-Apr-05 4:01 
GeneralRe: Access File Copy Pin
Blake Miller1-Apr-05 4:58
Blake Miller1-Apr-05 4:58 
GeneralDLL question - correction Pin
eli1502197931-Mar-05 23:46
eli1502197931-Mar-05 23:46 
Hi,
I need to write dll for another MFC application.
I've wrote the dll using MFC DLL wizard (regular dll using shared MFC dll).
In my DLL header there is th followung declarations:
#define TCPDLL_API __declspec(dllexport)
TCPDLL_API int WINAPI FLRInitializeIP(IPStruct *Server,int num_of_radars);



and in my "dll.def" there is the next declaration:
FLRInitializeIP	   @1



Also,the implementation of the function is:
TCPDLL_API int WINAPI FLRInitializeIP(IPStruct *Server ,int num_of_radars)
{
	struct hostent *Host;
	SIZE_T t=100;
	char *host_name = new char[100];
	gethostname(host_name,t);	
         Host = gethostbyname(host_name);
	Server->HostIP = inet_ntoa(*((struct in_addr*)Host->h_addr));
	delete []host_name;
	//Server->ClientsArray = new FLR_COMMUNICATION_DEVICE[num_of_radars];	
         //for(int i = 0 ; i < num_of_radars ; i++)
	//{	
         //	Server->ClientsArray[i].socket = INVALID_SOCKET;	
         //	Server->ClientsArray[i].IP_Address.Empty();	
         //}
	Server->Num_Of_Connected_Clients = 0;
         Server->ListeningSocket = INVALID_SOCKET; 
         Server->Num_Of_Radars = num_of_radars;
	if(CreateTCPServerSocket(Server) != LISTEN_SUCCESS)
		return 0;//LISTEN_FAILED;	          
         return 1;//LISTEN_SUCCESS;
}



Finally,I'm using the dll :
typedef int (CALLBACK* FLRInitializeIP_PROCCESS)(IPStruct* ,int);
void CDLLTestDlg::OnListenButton()
{
    HINSTANCE hLib;
    FLRInitializeIP_PROCCESS FLRInitializeIP;
    IPStruct Server; 
    int result;
    hLib = LoadLibrary("TCP_DLL.dll");
    FLRInitializeIP = (FLRInitializeIP_PROCCESS)GetProcAddress(hLib,"FLRInitializeIP");
    //(FLRInitializeIP)(&Server , 1);
    result = FLRInitializeIP(&Server , 1);  
    m_List.AddString(Server.HostIP);
    FreeLibrary(hLib);
}


Well,I don't get compilation errors,but if the return value
of FLRInitializeIP() is anything else but "void"- i get run time error(something about convention error...).
But, if the return value is "void" there is no error.
When i'm debugging my code - the function works fine and the
error accurs after
return 0

or
return 1



Can anyone help me with this error?
Is there good tutorial about dll programing?
Maybe I've wrote the wrong DLL project?

Regards,
Eli Confused | :confused: Cry | :((
GeneralRe: DLL question - correction Pin
Alexander M.,1-Apr-05 2:37
Alexander M.,1-Apr-05 2:37 
GeneralRe: DLL question - correction Pin
eli150219791-Apr-05 2:46
eli150219791-Apr-05 2:46 
GeneralRe: DLL question - correction Pin
vishalmore1-Apr-05 20:44
vishalmore1-Apr-05 20:44 
GeneralDLL question Pin
eli1502197931-Mar-05 23:26
eli1502197931-Mar-05 23:26 
GeneralRe: DLL question Pin
Cedric Moonen31-Mar-05 23:28
Cedric Moonen31-Mar-05 23:28 
GeneralRe: DLL question Pin
eli1502197931-Mar-05 23:50
eli1502197931-Mar-05 23:50 
GeneralRe: DLL question Pin
toxcct1-Apr-05 1:59
toxcct1-Apr-05 1:59 
GeneralWave file player using drag bar. Pin
hasansheik31-Mar-05 23:12
hasansheik31-Mar-05 23:12 
GeneralRe: Wave file player using drag bar. Pin
Alexander M.,1-Apr-05 2:40
Alexander M.,1-Apr-05 2:40 
GeneralRe: locked workstation and stack overflow Pin
Alexander M.,1-Apr-05 2:53
Alexander M.,1-Apr-05 2:53 
GeneralLooking for tool to translate my soft Pin
yarp31-Mar-05 23:00
yarp31-Mar-05 23:00 
GeneralRe: Looking for tool to translate my soft Pin
John R. Shaw31-Mar-05 23:34
John R. Shaw31-Mar-05 23:34 
GeneralRe: Looking for tool to translate my soft Pin
yarp1-Apr-05 1:29
yarp1-Apr-05 1:29 
GeneralYour Opinion... Pin
NewbieStats31-Mar-05 22:59
NewbieStats31-Mar-05 22:59 
GeneralRe: Your Opinion... Pin
ThatsAlok31-Mar-05 23:11
ThatsAlok31-Mar-05 23:11 
QuestionHow to get USB Mass Storage Device info? Pin
delemur31-Mar-05 22:46
delemur31-Mar-05 22:46 
GeneralHook chains Pin
Member 44888031-Mar-05 22:38
Member 44888031-Mar-05 22:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.