|
ScotDolan wrote: For what i am learning, it seems like WSAAsyncSelect() with WSAGETSELECTERROR marco might be a better solution than WSAEnumNetworkEvents(client_socket, g_hClientEvent, &NetworkClientEvents);
It seems that WSAAsyncSelect() will provide me with more information and less chance of missing a event.
Unless you're using a buggy socket implementation, you won't miss any events using either method.
The difference is, WSAAsyncSelect uses a window to notify you. WSAEventSelect uses an event.
The window method is only really useful if you want to do asynchronous socket ops in a single
threaded app. If you have a separate thread for socket communication then an event is easier
and more efficient (the thread can wait on the event).
I'm not sure what you're getting at with the FD_CLOSE errors. I wouldn't expect any error
(or even look for one). After receiving the FD_CLOSE notification there's nothing that can
be done on the socket except reading any remaining unread/buffered receive data.
Mark
|
|
|
|
|
Also, see Mike's post below
|
|
|
|
|
Don't use a switch statement to check the network event. More than one event can be signalled at a time. The events will be OR 'd together.
Mike
|
|
|
|
|
Thanks Mike!
I didn't even think about that....I just copy/pasted from the OP's code
Mark
|
|
|
|
|
I didn't realize it was the OP's code (which was so long and unformatted that I barely even glanced at it). Sorry.
Mike
|
|
|
|
|
No problem. I always appreciate a heads up when I'm wrong
|
|
|
|
|
Hi,
I am using the Windows API to write some code that uses the end user's already installed Adobe Acrobat Reader to open up a *.PDF file. My problem is locating the file. Everytime Adobe upgrades to another version of Adobe Acrobat the pathname changes, say for example from
C:\Program Files\Adobe\Acrobat 5.0\Reader\Acrord32.exe
to
C:\Program Files\Adobe\Acrobat 7.0\Reader\Acrord32.exe
which at the moment causes the routine to fail unless I have specified the correct directory.
I am guessing there must be a much better way to do this, could anybody point me in the right direction? I would assume that you can ask the operating system what *.exe it uses to open up *.pdf and tell it to use that, but I am unsure how I code that.
Could someone point me in the right direction?
Thanks,
Joe
|
|
|
|
|
You can call ShellExecute using as argument the path of the document to open (instead of that of the executable, see MSDN documentation for details...).
hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
TheDelChop wrote: I am guessing there must be a much better way to do this, could anybody point me in the right direction? I would assume that you can ask the operating system what *.exe it uses to open up *.pdf and tell it to use that, but I am unsure how I code that.
http://visualcpp.org/template_permalink.asp?id=125[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Dear All.
I need to create a Bitmap output file from statistical data without showing to screen. The image will be built in memory and then output to file. I will need to do this in VC++ SDK, not MFC. Can anyone point me in the right direction on this one? (Books / examples / links... etc) I've tried looking around and there are lots of examples of Loading bitmaps and outputting to screen but none on building and outputting from memory.
Many thanks
u6ik
|
|
|
|
|
Are you wanting to know the format of a .bmp file?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You can create a memory device context by means of CreateCompatibleDC (see the related documentation) then use the GDI primitives to draw on it (all the example you have also applies to memory device context).
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Do you want to create a graphic file?
|
|
|
|
|
Yes. A BMP file which can be opened using any BMP viewer.
I know how to handle files, but what to put in it, that's the problem.
Cheers
u6ik
|
|
|
|
|
Hi all. I was trying to get a better understanding of the winAPI function WaitForMultipleObjects() - I searched msdn for a answer to what it is/does etc. But i didnt fully understand what it was trying to tell.
<quote>
This function returns a value when either any one of the specified objects is in the signaled state, or the time-out interval elapses.
That was the definition for it <url=http: msdn2.microsoft.com="" fr-fr="" library="" aa450987.aspx="">here
If anyone could give me a address to where i can find a fully detailed description of the function i'd be very greatful. Or if they could take the time to exaplain. Thanx in advance!
|
|
|
|
|
What exactly is it that you don't understand? Once the function is called, it waits. Objects start life in a non-signaled state, and can later be set to a signaled state, which the function recognizes.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Does anyone has an idea why the diff = difftime(my2, my1); fragment in the following code returns always zero?
char date1[60], date2[60];
struct tm mytime, mytime2;
time_t my1, my2;
mytime.tm_isdst = -1;
mytime.tm_year = 2006;
mytime.tm_mon = 1;
mytime.tm_mday = 1;
mytime.tm_hour = 0;
mytime.tm_min = 0;
mytime.tm_sec = 0;
my1 = mktime(&mytime);
strftime(date1 ,60 , "%x", &mytime2);
mytime2.tm_isdst = -1;
mytime2.tm_year = 2006;
mytime2.tm_mon = 1;
mytime2.tm_mday = 3;
mytime2.tm_hour = 0;
mytime2.tm_min = 0;
mytime2.tm_sec = 0;
my2 = mktime(&mytime2);
strftime(date2 ,60 , "%x", &mytime2);
diff = difftime(my2, my1);
printf(date1);
printf(date2);
printf("Difference in seconds: %f\n", diff);
Regards,
Deian
|
|
|
|
|
Deian wrote: strftime(date1 ,60 , "%x", &mytime2);
Should probably be:
strftime(date1 ,60 , "%x", &mytime1);
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello David,
the problem line is diff = difftime(my2, my1);
no matter what date I construct, it always returns 0.
strftime(date1 ,60 , "%x", &mytime1); just put's the date in the date1 variable for display, ignore this typo.
|
|
|
|
|
Deian wrote: the problem line is diff = difftime(my2, my1);
No, the problem is with both calls to mktime() . Notice that my1 and my2 will both be -1 because you are using an invalid year. It's always handy to check the return value of a function.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks for the help David,
1) The actual problem was me overlooking the struct tm structure
2) Under Dev-C++ IDE, the program compiles, but the mktime /difftime functions are not working correctly. Pasting the same code over VC++ 6 IDE results in working app, with correct calculation of the period passed to both functions.
Regards,
Deian
|
|
|
|
|
You haven't properly initialised the tm structs.
In details:
(1) you missed the initialization of the following members:
tm_wday
tm_yday
i.e. the day of the week and the day of the year. [MODIFIED: seems this step is not required].
(2) If you intend to indicate the year 2006 then you have to set tm_year=106 .
(3) the month is (like the day of the week and the day of the year) 0-based. So tm_mon = 1; indicates february (not january) .
(4) About tm_isdst , I don't know, maybe correct.
Please note also the error found by David.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
CPallini wrote: (1) you missed the initialization of the following members:
tm_wday tm_yday
(3) the month is (like the day of the week and the day of the year) 0-based. So tm_mon = 1; indicates february (not january) .
(4) About tm_isdst, I don't know, maybe correct.
These have nothing to do with mktime() failing, however. It all had to with mtime() interpreting the year as 3906.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: These have nothing to do with mktime() failing, however. It all had to with mtime() interpreting the year as 3906.
Yes, as well as
DavidCrow wrote: strftime(date1 ,60 , "%x", &mytime2);
the OP was a bit confused, I though opportune to point out all the mistakes (related and unrelated) as well the possible mistakes, to help him to have a better understanding of the matter.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|