|
Something that seems strange to me is that you don't define the types of your parameters. And the types of the parameters is very important for a function signature. So, this is a flaw I see in this design.
Also, why do you want to provide such mechanism ? The functions in the dll are known and if you want to call them, you know their prototypes. Or am I missing something ? If you could provide some informations there it will be usefull. Like explaining why do you want to achieve such a thing, maybe there is another solution.
|
|
|
|
|
yes but I would like to define them on runtime, not static.
I want this for simple scriptting language which can call any api from system.
-- modified at 6:46 Wednesday 26th July, 2006
|
|
|
|
|
There is no easy way of doing that. You'll have to use some powerfull techniques like template for example but I cannot give you a complete solution like that (I don't have one myself).
Using a dll increase a lot more the difficulty cause to load a function, you need to know its function prototype (that is statically defined) so, I don't think this is feasible.
|
|
|
|
|
I am developing a network application using CAsyncSocket.
I have OnReceive() overridden to read data (as does everyone I guess!)
All is fine - the application is successfully receiving data from the peer - until suddenly the calls to OnReceive() cease. For debugging, I also call ioctlsocket() with FIONREAD, and this reports that there are zero bytes in the network read buffer when the OnReceive() calls stop.
However, if I force a new call to OnReceive() this proves that definitely IS data available - as more data is read. Also, calling AsyncSelect() when the stall occurs, DOES trigger a new call to OnReceive(). However I don't want to schedule calls to AsyncSelect() - I shouldn't have to - and that would cause a performance hit anyway.
The stall occurs regularly - usually at least once every minute. An occasional missed call to OnReceive() would be tolerable, but this is ridiculous!
There are similar issues noted on the internet, e.g.
http://groups.google.co.uk/group/microsoft.public.vc.mfc/browse_thread/thread/26f6d6cb0151c2ad/6ed6994c7bcdf45c?lnk=st&q=&rnum=3&hl=en#6ed6994c7bcdf45c
.. but I have not seen a proper explanation, let alone resolution, and I have run out of things to try / debug.
Any help very gratefully received!
cheers,
Neil
|
|
|
|
|
I might be misremembering this, but doesn't there have to be a read pending before receive notifications are sent?
(Normally I use raw sockets, or a custom class to manage TCP/UDP stuff, so my memory is a bit hazy on this one)
Steve S
Developer for hire
|
|
|
|
|
Hi Steve
Thanks for replying.
I think a read IS pending. The problem is that the socket seems to "go to sleep" and it is necessary to call AsyncSelect() to make the framework realise data can be read.
cheers,
Neil
cheers,
Neil
|
|
|
|
|
I never came across this problem in my network applications. I wonder how your code in the OnReceive() handler looks like?
|
|
|
|
|
No, I think you are right.
At the time I was using code from OpenSSL, and I think that causes some strange things to happen. I changed my algorithm, and now it is fully working. So I don't think there really is a bug with the MS software, you just have to be careful with these functions, and call them at the right times etc.
cheers,
Neil
|
|
|
|
|
hello,
In my application i am using the GetVersionOfFile() in MFC Application;
i Have doubt about the a and b . any idea about dat
GetVersionOfFile(szAppPath , a , 256 ,b ,256);
szAppPath->path of file
a->?
256->?
b->?
256->?
janan
|
|
|
|
|
ningthemcha wrote: GetVersionOfFile() in MFC Application
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
a-> VersionBuffer
b-> Language Buffer
Here is the code for the function.
void GetVersionOfFile (char * pszAppName,
char * pszVerBuff,
int iVerBuffLen,
char * pszLangBuff,
int iLangBuffLen)
{<br />
DWORD dwScratch;<br />
DWORD * pdwLangChar;<br />
DWORD dwInfSize ;<br />
UINT uSize;<br />
BYTE * pbyInfBuff;<br />
char szVersion [32];<br />
char szResource [80];<br />
char * pszVersion = szVersion;<br />
<br />
dwInfSize = GetFileVersionInfoSize (pszAppName, &dwScratch);<br />
<br />
if (dwInfSize)<br />
{<br />
pbyInfBuff = new BYTE [dwInfSize];<br />
memset (pbyInfBuff, 0, dwInfSize);<br />
if (pbyInfBuff)<br />
{<br />
if (GetFileVersionInfo (pszAppName, 0, dwInfSize, pbyInfBuff))<br />
{<br />
if (VerQueryValue (pbyInfBuff,<br />
"\\VarFileInfo\\Translation",<br />
(void**)(&pdwLangChar),<br />
&uSize))<br />
{<br />
if (VerLanguageName (LOWORD (*pdwLangChar),<br />
szResource,<br />
sizeof(szResource)))<br />
{<br />
strncpy (pszLangBuff, szResource, iLangBuffLen);<br />
}<br />
wsprintf (szResource, "\\StringFileInfo\\%04X%04X\\FileVersion",<br />
LOWORD (*pdwLangChar), HIWORD (*pdwLangChar));<br />
<br />
if (VerQueryValue (pbyInfBuff,<br />
szResource,<br />
(void**)(&pszVersion),<br />
&uSize))<br />
{<br />
strncpy (pszVerBuff, pszVersion, iVerBuffLen-1);<br />
}<br />
}<br />
}<br />
delete [] pbyInfBuff;<br />
}<br />
}<br />
}
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Hey, we don't get many psychics on CP.
If I send you some function prototypes, can you send me some source back
(I checked the online MSDN and there's no MFC function documented called that, although I would have guessed that a and b were buffers, and the two constants were buffer sizes.)
Steve S
Developer for hire
|
|
|
|
|
What happens when an Object of CWinApp derived Class is Created in MFC ??
Can Somebody answer my above question .
Thanks in advance.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
What are the actions that takes take when I say CMyApp theApp;
in MFC Application ??
Looking forward for your reply.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
What are the actions that takes place when I say CMyApp theApp;
in MFC Application ??
Looking forward for your reply.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Patience is a virtue, and virtue brings it's own reward.
When the app is loaded, the constructor is called, which is done before WinMain (from the MFC library, unless you provided your own) is called. Mostly, this will just result in the base constructor(s) being called. Mostly, this just sets some object-specific data, and initialises the various state stuff used by MFC.
WinMain is then responsible for calling the object's InitInstance(), which usually triggers window creation and stuff like that.
Of course, the MFC source is available, which is where I found this.
Steve S
Developer for hire
|
|
|
|
|
Steve S wrote: Patience is a virtue, and virtue brings it's own reward.
I am so sorry 4 posting the same twice..It happend accidently.
Thanks for the reply.
Can you provide me some link,which explains the steps in detail ??
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
No I can't, although there's probably an MSDN article on it somewhere.
But then, you could use the Star Wars technique to find out ("Use the source, Luke").
Use find in files from the IDE to look for ::CWinApp in the MFC source folder, and that should take you to step#1.
From there, you can simply work your way through the code, checking out the various bits of code as you go.
There's a book called "MFC Internals" which is probably out of print, not to mention being out of date (I have a copy at home, ~140 miles away, so I can't check the last MFC version it covered).
Apart from academic curiosity, why would you want to know?
Steve S
Developer for hire
|
|
|
|
|
I've posted a question about my aplication blocking because it reads the com continuesly and I got the answer of using threads. But reading about it i found out that: "The thread remains active as long as the thread's function is executing" so I don't see how that helps. My thread will remain active forever because i'm using a function wich has a while loop to listen to the com port, a while loop which never ends. I want to be able to acces the menu of my aplication so I can put a menu comand like stop listening. Am I wrong or isn't a worker thread the answer for me?
|
|
|
|
|
How u created the thread.
Is it CreateThread API ?
rgds
aneesh
|
|
|
|
|
I use AfxBeginThread. Shouldn't I use a separate process that deals with the reading of the COM?
-- modified at 3:15 Wednesday 26th July, 2006
|
|
|
|
|
See Here[^] maybe it is some helpful to you
|
|
|
|
|
Typically, your thread will loop continuously, with checks to see if (a) the current read has timed out, in which case you continue, or (b) an event was trggered (See CreateEvent in the API docs), in which case the thread exits. That way, you can trigger the event in your main thread when you want to quit the app, and then wait in the main thread for the comms thread to exit.
You can combine the two by using COMMS events and waiting until either a received character is available or the other event was triggered, and acting accordingly.
P.J.Naughter has written some excellent classes, one of which deals with comms ports, so check that out in the MFC/C++ libraries section here on CP.
Steve S
Developer for hire
|
|
|
|
|
Did you read this article from your last COM-related post? It goes into detail on how threads can be used for reading (and writing). Now your main UI thread can remain responsive.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
hi, does anybody know how 2 add a 3DS object in VC++.
When the goin gets tough then tough gets going
|
|
|
|
|