|
I would first like to mention that your specific problem has nothing to do with the MFC DLL. You have the same problem if it was a regualr' NOn-MFC' DLL.
You need to make the function signatures match the pascal calling convention.
I usually give all regular 'C' functions exported from a DLL the pascal calling convention, unless otherwise required. One exception, for example, is if the function has a variable number of arguments.
Especially since you declared that the function has this signature:
typedef int (CALLBACK* FLRInitializeIP_PROCCESS)(IPStruct* ,int);
And in WTYPES.H there is this definition:
#define CALLBACK FAR PASCAL
You need to define the function ion the DLL with the same signature, like this:
#define TCPDLL_API __declspec(dllexport)
TCPDLL_API int WINAPI FLRInitializeIP(IPStruct *Server,int num_of_radars);
TCPDLL_API int WINAPI FLRInitializeIP(IPStruct *Server , int num_of_radars){
|
|
|
|
|
Hi,
First - thanks for your prompt reply.
well,i'v tried your suggestion,but it's still give me run time error(something about convntion - as you said).
Here is what i did:
Instead of :
TCPDLL_API int FLRInitializeIP(IPStruct *Server,int num_of_radars);
I've wrote :
TCPDLL_API int WINAPI FLRInitializeIP(IPStruct *Server,int num_of_radars);
and instead of :
TCPDLL_API int 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->Num_Of_Connected_Clients = 0;
Server->ListeningSocket = INVALID_SOCKET;
Server->Num_Of_Radars = num_of_radars;
if(CreateTCPServerSocket(Server) != LISTEN_SUCCESS)
return 0;
return 1;
}
I've wrote :
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->Num_Of_Connected_Clients = 0;
Server->ListeningSocket = INVALID_SOCKET;
Server->Num_Of_Radars = num_of_radars;
if(CreateTCPServerSocket(Server) != LISTEN_SUCCESS)
return 0;
return 1;
}
Now,when I'm debugging my code - the function works well and the run time
error accurs after the :
return 0;
or
return 1;
So,where is the problem???
Again - thanks for your help.
With best regards,
Eli
|
|
|
|
|
I am not sure. Usually when you crash on a 'return' from a function it is because your stack has been corrupted. Perhaps something done inside CreateTCPServerSocket is the culprit.
I am also suspicious of this line
Server->HostIP = inet_ntoa(*((struct in_addr*)Host->h_addr));
because if the Server->HostIP is only a pointer to a string and not the buffer itself, you might be losing the string because of this warning from MSDN regarding the string returned from inet_ntoa:
The data is guaranteed to be valid until the next Windows Sockets function call within the same thread—but no longer. Therefore, the data should be copied before another Windows Sockets call is made.
I think you should check this string assignment, and make sure it is COPYING the string and not just assigning the address, and also look into CreateTCPServerSocket to make sure it does not overwrite some local variables that would be resulting in the corrupted stack.
|
|
|
|
|
Me: looking to fill C++/Linux and TCP/IP programming position in NYC.
You: Fantastic programmer looking for interesting position in NYC.
Please send me a resume.
|
|
|
|
|
Are you sure that this is the right website for linux job offers?
It's a windows site
Don't try it, just do it!
|
|
|
|
|
|
|
Me: looking to fill ______programming position in NYC.
You: Fantastic programmer looking for interesting position in NYC.
Please send me a resume.
|
|
|
|
|
Hello. I need help.
The question is... I want to move all row. From row 10 to row 4 using a Drag Drop.
How can I do it?
Thanks
Xavier
|
|
|
|
|
Hi Forum,
i need help by retriving the current user password, in my application user can create a task to schedule, but i dont want that the user inputs him password and name, this should be comming from the funktion, the user name i get with the GetUserName() method but i need hims password to create a task! Is that any known method for this? method NetUserGetInfo() retrives me a empty string so i can't take it, example :
NetUserGetInfo( NULL, user_name, 1, (byte **) &info );
CString strUserPassword = info->usri1_password;
strUserPassword is empty now!
thanx for help
mirsad
|
|
|
|
|
ähm, im not Anonymous, its my posting,
mirsad
|
|
|
|
|
You have to ask the user for his password.
For security purposes, there is not a readily available API to retrieve the user's password. Else every trojan, worm, and virus out there would be using it.
|
|
|
|
|
|
thanx for answers,
for example, when i create a task for my antivirus programm to start every day in 00:00 time, i dont need a passwort, and the task is valid, that is because i thing that is possible, and i know, a new task whitout a USERNAME and PASSWORD will NEWER start, how is that possible?! that is thrue! So i look for a new solution to create a new task whitout a needs to user inputs him's password! The username is not a problem! There must be a way to due this, the people from symantec due the same
thanx
mirsad
|
|
|
|
|
Actually Power Behind Symantec Anitvirus is that it's running it's scanning engine as a Window Service(which run on Administrative Priviledge)
keep smilling.....b'coz smile is the shortest distance between people....
|
|
|
|
|
sigh:
|
|
|
|
|
I would like to know about the Compatabilty between windows 95 &windows 98 device drivers. Can a device driver running on win95 successfully be run on win98 without any upgradation? Can the device drivers be used on both the platforms interchangeably?
TELL ME WHY
|
|
|
|
|
The biggest difference between windows 95 and 98 is that 98 supports plug and play (WDM drivers) and 95 does not.
That would mean that you can use win95 drivers for windows 98, but not vice versa (should be the same with NT and 2k).
Don't try it, just do it!
|
|
|
|
|
Thanks Alexander. Would also like to know :
How to write device drivers compatible with both Win 95/98 – resources, steps, what development tools are needed, etc.
If you could please guide further.
Thanks & Regards
Neha
Tell me why
|
|
|
|
|
Your best bet would be to look at the Windows DDK and samples to learn about specific platform differences. Knowledge of assembly and C are helpful.
|
|
|
|
|
Have a look at the Windows DDK. When you want to use the same driver for Win98 and Win95, you can't use WDM.
The Windows DDK includes the headers, libs, docs and a compiler for the source code. But I'm not sure if the Win95 DDK still exists since Microsoft stopped the support for this product some time ago.
Don't try it, just do it!
|
|
|
|
|
Hi I've rewritten one of my MFC Dialog-apps into an ActiveX. How do I debug it?
_____________________________
...and justice for all
APe
|
|
|
|
|
I normally set the program to execute to the ActiveX Control Test Container. In VS.NET 2003, go to Project Properties, Debugging, click in Command (under Action) and use the drop-down list to pick ActiveX Control Test Container.
In VS6, go to Project/Settings, then the Debug tab. Click the right-arrow next to 'Executable for debug session' and pick ActiveX Control Test Container from the list that appears.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks!
_____________________________
...and justice for all
APe
|
|
|
|
|
How to make my program fullscreen initially? i mean, i'd like my program to run with fullscreen mode(not maximized) just when it starts. Should i do something in mainframe::OnCreate?
i don't like a fullsreen toolbar to help me quit from fullsceen mode. so, can i quit from fullsreen mode by pressing 'ESC'? How to?
Need your help. Thanks first!
akeye
|
|
|
|