|
It's a generic class for all instances of work that's i/o bound.
Specific uses are filters and hashes which take a score or so
of cycles per byte of data. (much less than time to read the data)
I'm allocating the buffers on the stack and using overlapped i/o
but wasn't sure if the operating system was actually able to
asynchronously read the data or if just spawned another thread to
do it.
If it's just another thread, for a single processor, it'd seem
better to just use a memory mapped file right? No overhead for
the wait operations and processor is fully tied up reading
(on each page fault) or processing.
If overlapped i/o really is asynchronous on a single processor,
then what I've got now should be optimal.
Also I wonder, if the OS has the capability for real asynchronous
reads on a single processor, would it be using that to help
page in from a memory mapped file? Maybe the memory mapped file
can match the overlapped i/o technique because the os is smart?
(opened with sequential access for clue? I doubt but wonder.)
(yeah buffer sizes are calculated for optimal size-- you have to
pass working block size, processing cost and wait cost (about 10K
cycles I found from experiments on XP) for the overlapped i/o--
it can be shown that optimal # of rounds is independent of read
cost assuming that it's greater than processing cost.)
Thanks!
|
|
|
|
|
Hi! I have this sort of set up in my code:
FILE *gen; int i;
gen = fopen("data\\gen.dat", "r");
fscanf(gen, "%c", &i);
Now at this point in the code the next couple of bytes are useless. How do I skip them out? I could run fscanf a couple of times but Im positive this is not the best solution.
Thanks!
|
|
|
|
|
|
use seek or fseek
- Shailesh
|
|
|
|
|
If it's just a couple of bytes, there is nothing wrong with using an additional fscanf() . Just read the bytes into a variable named something like extra or fluff .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
bRes = PlaySound( (LPCTSTR)SND_ALIAS_SYSTEMASTERISK, NULL, SND_ALIAS_ID | SND_NOSTOP | SND_ASYNC | SND_NOWAIT );
Works fine with all Windows platforms except Win ME. The crash only occurs when trying to play system sounds.
Is there something to do?
Thanks!
|
|
|
|
|
Hi All!
I have to write a client application which would use sockets to get data from partucular device via TCP\IP. Client code will reside in dll and should run under Windows 98 - XP. I think I can use WinSock 2.0 for this, but the problem is that my application should be easily ported to Linux later. Of course it cannot be just recompiled, but i have to acheive best compatibility possible to make my life more easy later when porting time comes. Unfortunately my knowledges regarding sockets are just theoretical. Could you please, suggest me what should be avoided to make WinSock 2.0 (or 1.1) based solution more or less portable to BSD based sockets solution. I understand that WinSock was written based on BSD sockets API but anyway, there should be something wrong Additionally, data sending, receiving, connection process will be run in separate threads, so some comments regarding portable notifications (or solutions to be notified) of task completion would be very helpful. If the topic is too large then could you please, point me to some Article which covers the problem?
Thanks in advance!
Best regards,
Dima
|
|
|
|
|
Short answer:
If you look at the winsock api reference most of the functions that start with a lower case letter are portable. The ones that start with and upper case letter are MS specific.
So, for example, you would use:
socket, accept, connect
as opposed to:
WSASocket, AcceptEx, ConnectEx
As for portable notifications ...
I find IOCP to be too usefull to ignore in the name of portability.
I would suggest this for windows.
There are number of good articles here on using IOCP.
For UNIX either mimic IOCP, use select, or roll you own.
In the end i would suggest you write a socket class that hides the OS specific issues.
Create one optimized for windows and another for unix, but both with the same public interface.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Does anyone have any idea of how to do what Windows Explorer does in the "Folders Options/View/Advanced Settings": Use radio buttons in a standard system treeview?
I checked out this article (XP theme aware TreeView control which supports checkbox and radio button nodes), but it's using .net and it seems to be using bitmap images (I could be wrong though). I just want to use Win32 APIs to do this. I think it should be possible because in the Platform SDK, it states that "When set to this style [TVS_CHECKBOXES], the control effectively uses DrawFrameControl to create and set a state image list containing two images"; however, I tried to imitate this to no avail. I tried using DrawFrameControl but it always draws the flat, non-themed styled control (all other controls in the window is correctly drawn with the XP theme looks).
Please help! Any advice is much appreciated!
Thanks.
Ken
|
|
|
|
|
Hi all,
I have written a DLL that is statically linked to the MFC and it #imports ADO just like this...
#pragma warning(push)<br />
#pragma warning( disable : 4146 ) // ADO compile warning cannot be avoided<br />
<br />
#import "c:\Program Files\Common Files\System\ADO\msadox.dll"<br />
<br />
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF","EndOfFile")<br />
<br />
#pragma warning( default : 4146 ) // Restore warnings for rest of application<br />
#pragma warning(pop)
My DLL has a global variable defined as :
_ConnectionPtr pConn;
The first function exported calls CoInitialize(NULL) and this works fine.
Next some other exported function calls use the pConn variable to check if we can connect to a given database. This works fine and no exceptions are created.
The last function exported calls ::CoUninitialize() and this works ok.
My problem at the moment is that after I call the last exported function I then close my test application. When I close my test application I am getting a serious access violation as follows:
'Unhandled exception in (MSDART.DLL) 0xC0000005: Access Violation'
I have MDAC 2.71.9040.2 installed. I am running on Windows 2k and using MSVC6.0.
Any ideas you can offer me would be greatly appreciated.
Kind Regards,
Chris
|
|
|
|
|
You need to set pConn to NULL before calling CoUninitialize(), it's destructor is being called by your app's exit. A _com_ptr's destructor calls Release on the interface pointer if it's not NULL, and the results after calling CoUninitialize() are undefined. Good luck.
|
|
|
|
|
That solved it. Thank you very much!
Chris
Anonymous wrote:
ForumVisual C++
Subject:Re: ADO Crashing big time!
Sender:Anonymous
Date:13:04 27 Sep '04
You need to set pConn to NULL before calling CoUninitialize(), it's destructor is being called by your app's exit. A _com_ptr's destructor calls Release on the interface pointer if it's not NULL, and the results after calling CoUninitialize() are undefined. Good luck.
|
|
|
|
|
<big><small><small><pre>:laugh::confused: -O
|
|
|
|
|
May be he is Learning ABCD
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Afternoon Gents (and ladies)
I'm writing an app that uses some information from windows settings to set layout metrics. I've retrieved all the metrics information successfuly, but i'm not sure how to detect when it's changed.
I'd like to have the settings fixed for my object and changed only when the windows appearance is modified, as currently they are tested and updated on every redraw action.
I'm making this component in C#, but i'm looking for the system event to marshal into my program as it will dramatically improve efficiency.
Cheers
Cata
|
|
|
|
|
You should be fine if you handle the WM_SYSCOLORCHANGE message. You could then refresh your color cache. In C#, you have to handle the SystemColorsChanged for the form or control.
Yves
|
|
|
|
|
Thanks, but it's not just the colour.
It's the text size, border sizes, and whether themes are enabled / disabled in XP. If a user changes these without changing the colour, then it won't update properly. I'm sure I read about a system metrics change method somewhere, but it was in the windows SDK.
Any other thoughts?
Cata
|
|
|
|
|
Hello,
I am sure this may have been dealt with by somebody. I am wondering how to load an own bitmap image in place of miscrosoft default icon in VC++ application.
Thanks for help in advance.
Murali
|
|
|
|
|
do you mean the icon in the about box or on the title bar? Just add it to the resource under icon IDR_MAINFRAME. For the about box you could add a picture control and add the bitmap to the resource as a bitmap and have the control reference that bitmap.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
I am looking to change the icon at the title bar and the icon in the taskbar of windows when the application is executing. Also, I have only a bitmap of the image. Can you please tell me how I should add my bitmap image to application to show up in title and taskbars.
thanks
Murali
|
|
|
|
|
The icon for the title bar and the task bar come from the icon. Two ways to do this.
1. Convert your bitmap to a .ico file. Microangelo is a great tool to do this.
2. Import in the bitmap. Then copy and paste it over the icon. Both the 32x32 and the 16x16 icons. The only problem with this is that it will distort the bitmap some and sometimes does not look very nice.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Thanks Tom,
I was just following similar to steps you outlined while your email just arrived listing them ). Thanks again. Yes, that is true I lost some resolution in process of step 1 but that is OK for now.
One thing I did (before your email arrived) was generated the *.ico file using "CDMenu V2" trial version of software I obtained from internet. It worked well. However, I COULD NOT get my application to work with ONLY the 32X32 bitsize icon. I am not clear why this was so?
However, after reading your email and creating the 16X16 bitsize icon file as well, then it all worked. Can you explain why only the 32X32 icon file is not sufficient.
Thanks again
Murali
|
|
|
|
|
Is there some type of message I can set up or receive so that my app can tell when a new file is added to a particular folder?
[insert witty comment here]
bdiamond
|
|
|
|
|
|
There's also FindFirstChangeNotification() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|