|
Hi,
you're welcome.
ginjikun wrote: left it running for over 2 hours
you could get more testing done by decreasing the time in between communications; just
for testing purposes reduce the period from 1 minute to 10 seconds, or 1 second. That way
a 1 hour run simulates an actual run of 6 or 60 hours...
ginjikun wrote: how exported functions behave. is it blocking?
is several threads of the same process, or some threads of different processes, call
the same function in a (shared) DLL, then they will run any way they see fit, there is
no automatic blocking, locking, synchronization, whatever; so either your code must
be "thread-safe" (i.e. withstand such concurrent execution), or explicit locking must
be provided.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
It would be helpful if you could paste more detail of the code instead of just the summary. In that function the "function1 Exit" was not printed for both those concurrent calls ?
|
|
|
|
|
Hi Llasus!
the "function1 exit" was printed after it encountered the error "The system cannot find the file specified.".
function1 called is just like as i have posted it less the checking and the other function calls like PeekNamedPipe to avoid cluter. it just calls CreateFile if successful then calls WriteFile and then calls ReadFile then CloseHandle. but in CreateFile it already fails
function1(pipename, data)
{
if(CreateFile(pipename...))
{
WriteFile(data...);
ReadFile(reply...);
Closehandle(...);
}
else
{
Log(GetLastError());
}
}
thanks again!
old
|
|
|
|
|
The code is too little to somehow point-out where the problem can be. Paste more of your codes. As far as I can guess, since it had successfully operated for an hour and failed after that, it seems that at some point some pipes wasn't released/closed properly which caused other clients to be unable to access the server (reached max 25 connections) and thus fails the CreateFile. Double check all the CloseHandle and DisconnectNamedPipe and make sure that your applications go to those part after using it. You can also paste more of your codes so that we can analyze it more.
|
|
|
|
|
Hi Llasus! thanks!
i have added some code in my latest reply to Luc. please refer to that one.
i have checked the log file and have so far found no failure in the releasing of the named pipe connection. also, if ever there are no more instances for the pipe to connect to, shouldnt the error be pipe busy or something similar to that? from the description
"The system cannot find the file specified." what i understand is that it is trying to connect to something which does not exist. i am not sure though
thanks for the help!
old
|
|
|
|
|
In that sample which you have pasted, in that function the "function1 Exit" was not printed for both those concurrent calls?
|
|
|
|
|
Hi Llasus!
the "function1 exit" was printed after it encountered the error "The system cannot find the file specified.".
function1 called is just like as i have posted it less the checking and the other function calls like PeekNamedPipe to avoid cluter. it just calls CreateFile if successful then calls WriteFile and then calls ReadFile then CloseHandle. but in CreateFile it already fails
function1(pipename, data)
{
if(CreateFile(pipename...))
{
WriteFile(data...);
ReadFile(reply...);
Closehandle(...);
}
else
{
Log(GetLastError());
}
}
thanks again!
old
|
|
|
|
|
ginjikun wrote:
the "function1 exit" was printed after it encountered the error "The system cannot find the file specified.".
If that's the case, since the client seems to close the pipes successfully after each use, then let's look at your server code. I checked the for loop of that code, after the ConnectNamedPipes() are the next set of codes inside the same for loop? or is it set within a separate thread for every ConnectNamedPipes()?
|
|
|
|
|
I'm new in Window API,I'm able to take handle and put target program SCR in front and able to capture Title. I would like to capture content chars of Client-Area. I'm using AS/400 terminal emulator which use TELNET to communicate with AS/400. I need to know which SCR, user is using now so that I am able to judge whether my other program can activate or not.
There is screen to measure weight and to measure total weight. When user press F3 on the screen, I capture weight from weighing machine, when user press F6 on the screen, I summarize weight and put it to keyboard buffer.
Problem is I don't know which screen user is using so that whenever user press F3, PC program get weight from weighing machine. To prevent it, I must know which screen user is using, in case of different screen I don't activate PC program.
|
|
|
|
|
Capture TEXT mean
Say for example, I have NotePad to which I have type some chars.
I look for "PACKAGE Weight:" inside chars.
If I find it, this is SCREEN what I want(F3=capture weight).
I look for "Total Weight:" inside chars, that is the SCREEN what I want (F6
=summarize weight)
So how do I get SOME CHARS from NotePad using API ?
AS/400 screen, still same I believe (I can copy -> paste to NotePad
and it is not IMAGE, chars, I can copy it)
|
|
|
|
|
Hi all. Im going to try my best in explaining on what i need. I have a program that downloads an update to the package. I havnt gotten so good that i can update the file with out stopping or closing it but this is the only solution i could come up with. In order for the new program to work the old one has to download it. Then open it. I used ShellExecute() to open the new program. Thats not the problem though. Well now that i have the new program in the install folder, i need to kick the old one. So what im trying to do is get it to delete any files that opened it. I'll make a brief description.
<quote>
old-file.exe opens new-file.exe
new-file.exe starts up and deletes old-file.exe
I cant make it any simple than that. I thought by using argv that would be a start in figuring it out but i dont know how. Any suggestions? Thanx in advance!
|
|
|
|
|
Using VC++2005, created a Windows Forms Application.
On the click of a button I execute a method from another class which takes a long time to process. Part of this process is adding GRAPHICS to a panel on the main window. How to I trigger the paint event on the window from this method? Is it possible that this method is not allowing events to be processed by the window/form?
|
|
|
|
|
nrbracke wrote: Is it possible that this method is not allowing events to be processed by the window/form?
Yes it's possible.
You can, however, force the window to get an immediate WM_PAINT message by invalidating part
or all of the window (see InvalidateRect()/InvaliateRgn()) and calling UpdateWindow().
Also, check out RedrawWindow(), which combines the above mentioned operations.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
If I Invalidate() the windows goes blank untill the method finishes its processing instead of updating with the components I have already added. What is preventing the paint method from getting called?
|
|
|
|
|
You need to call UpdateWindow() as well, so a WM_PAINT message gets sent to
the window. That window would need to actually draw in response to WM_PAINT.
You really should be doing lengthy operations on a separate thread if you want your
UI to stay responsive. By not letting the message loop run, you're preventing the UI
from getting and dispatching the messages it needs.
You could also periodically pump queued messages during your lengthy operation,
something like this:
<span style="color: Green;">
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!AfxGetApp()-> PumpMessage())
{
break;
}
}
<span style="color: Green;">
MSG msg;
while(::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
is there a way to add a popup menu to ClistBox control?
thanks
|
|
|
|
|
Gofur Halmurat wrote: s there a way to add a popup menu to ClistBox control?
One way would be derive a class from CListBox and add a WM_CONTEXTMENU handler
to the class. In that handler, use TrackPopupMenu() to show a popup menu.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I created a class which derived from CListBox, and I added WM_CONTEXTMENU handler, there is a problem, how can i use TrackPopupMenu()in the class?
I have the menus ID = IDR_MENU1, can i call it in the class? if so, how?
thanks
|
|
|
|
|
Gofur Halmurat wrote: I have the menus ID = IDR_MENU1, can i call it in the class? if so, how?
What did you try??
Take a look at TrackPopupMenu() in the PSDK or MSDN.
Here's one example:
CMenu popupmenu;
popupmenu.LoadMenu(IDR_MENU1);
...do some menu initialization if necessary...
int Command = (int)popupmenu.GetSubMenu(0)->TrackPopupMenu(TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, point.x, point.y, this);
...process the command... You can also use an appropriate window and catch the command message the normal MFC way.
You'd have to remove the TPM_RETURNCMD and TPM_NONOTIFY flags.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello Mark,
here is what i did in WM_CONTEXTMENU
<br />
popupmenu->LoadMenu(IDR_MENU1);<br />
int Command = (int)popupmenu->TrackPopupMenu(TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, point.x, <br />
point.y, this);<br />
when i click on the listbox, appears a bar(like 10x100), does not appear the menu, what do u think about why it doesnt show the menu?
thanks
|
|
|
|
|
Without seeing your menu resource, I have no idea.
Maybe try the first popup like I showed in my example...
...(int)popupmenu->GetSubMenu(0)->TrackPopupMenu(...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Also make sure you're tracking your menu resources....
You don't necessarily need to load the menu every time you get a WM_CONTEXTMENU
message - you can load it once, maybe in the constructor.
If you do choose to load it every time, make sure you release it
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
you are right, there should be GetSubMenu(0)-> , otherwise, it doesnt work,
It helped me alot
Thanks
|
|
|
|
|
Hello,
I have a question again, it shows the popup menu when i click rightbutton, but, how can we create popup menu message?
thanks
|
|
|
|
|
Hello,
Finally I understood that it should be like this
popupmenu->LoadMenu(IDR_POPUP); <br />
int Command = (int)popupmenu->GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, point.x, point.y, this);<br />
switch(Command)<br />
{<br />
case ID_POPUPMENU_EXIT:<br />
MessageBox("f***ing sh*t");<br />
break;<br />
}
thanks
|
|
|
|