|
Hello all,
I'm writing an application in which requires the list of processes currently running. Is there any to do it and also I would like to know whether we can can get handle to a specific process or not. I anyone knows how to do it, please help me.
Thanks for your help.
|
|
|
|
|
Look at EnumProcesses() in the psapi library.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi!
Are memory mapped files typically used for loading/saving speed, or is it just to handle incredibly large files?
I'm currently in a situation where I need to load and parse large
files (~20 MB) and I'm wondering about the different strategies for doing that as fast as possible.
Thanks
Shawn
|
|
|
|
|
They eliminate the need to hit the disk multiple times. With a 20MB file, you will notice a difference. With smaller files, the gain, if any, is negligible.
|
|
|
|
|
For some situations it's more convenient to use memory mapped files (e.g. if your file is structured with offsets to given items), and so that you can have a disk-backed data structure. It really simplifies programming such a shared structure - you don't have to explicitly read or write the file, you just read from or write to memory.
Note that there isn't any particular improvement in speed, nor any fewer disk hits: pages of a mapped view of a memory-mapped file are still paged in (and out) on demand.
SQL Server makes a lot of use of memory mapped files, IIRC.
If you're just reading a file sequentially, rely on the file system caching. It'll do much the same thing and is typically less complicated to program. To optimise the caching behaviour, pass the FILE_FLAG_SEQUENTIAL_SCAN or FILE_FLAG_RANDOM_ACCESS flags, depending on how you're using the file. If you specify one mode but your program actually reads the other way, performance is typically worse than if you hadn't specified either flag. Essentially FILE_FLAG_SEQUENTIAL_SCAN tells the system to read-ahead a lot and not at all behind, whereas FILE_FLAG_RANDOM_ACCESS tells it not to read ahead or behind very much. Specifying neither gives a compromise mode that does a little read-behind and some read-ahead. FILE_FLAG_SEQUENTIAL_SCAN causes pages behind the current file pointer to be discarded aggressively.
For information on how Windows 2000 file caching works, see Inside Windows 2000[^], chapters 7 (Memory Management) and 11 (Cache Manager). Basically the system implements caching by memory-mapping the files.
|
|
|
|
|
Mike Dimmick wrote:
Note that there isn't any particular improvement in speed, nor any fewer disk hits: pages of a mapped view of a memory-mapped file are still paged in (and out) on demand.
True, but for the last project I changed, I simply read from a CMemFile instead of a CFile, and the subsequent processing time could be measured in minutes instead of what used to take days. That's quite an improvement.
|
|
|
|
|
CMemFile is not a memory mapped file. It's a block of memory that conforms to the CFile interface, i.e., you can treat it as if it's a file.
True memory-mapped files are a different thing entirely.
|
|
|
|
|
I disagree. A CMemFile object is a memory file that behaves like a disk file except that the file is stored in RAM rather than on disk. A MMF, by definition, provides you with the capability to map a view of all or part of a file on disk to a specific range of addresses within your process's address space. Once that is done, accessing the content of it is as simple as dereferencing a pointer in the designated range of addresses. I fail to see how they are THAT different. In either case, once the file is read from disk and into memory, you operate on the file in its memory-mapped state, using the appropriate functions. The MSDN article Q142377 offers another view.
|
|
|
|
|
How do I send a carriage return and line feed through a serial port?
|
|
|
|
|
Do you know how to open and send data to a serial port using OpenFile() and WriteFile()??
char data[] = "\n\r";
DWORD dwBytesWritten;
WriteFile(hSerialPort,data,strlen(data),&dwBytesWritten,NULL);
John
|
|
|
|
|
John M. Drescher wrote:
char data[] = "\n\r";
Ummm, you might want to try "\r\n" instead
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Dear people:
I would like to be able to display the number of records of a table on the status bar and to jump to a record number based on user input. From what I read about Recordsets, this is impossible to do directly. Am I right? If so, how could I implement the above without having to traverse part of or the entire Recordset?
One idea I had for displaying the number of records was to use an auxiliary file that updates a variable every time an append or delete is done. This, however, would be quite messy if you have many tables and, of course, would not take care of my second issue of jumping to records. Thanks,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
RalfPeter wrote:
I would like to be able to display the number of records of a table on the status bar...
CRecordset::GetRecordCount() should work.
Jumping to a specific record is simply a matter of determining the difference between the current record number and the desired record number. If the difference is negative, you'll need to call CRecordset::MovePrev() X number of times. If the difference is positive, you'll need to call CRecordset::MoveNext() X number of times. After the moves are complete, then update the view.
You'll also want to consider the situation where there are 100 records and you want to jump to the 99th record. In this case, and others like it, it would be far less costly to jump to the last record and then call CRecordset::MovePrev() once rather than call CRecordset::MoveNext() 99 times!
|
|
|
|
|
Thank you for your reply. This was, however, my concern. From what you said, I will have to traverse at least part of the table. I was more like thinking of a table as an array. In an array, as you know, one may literally jump to an element, instead of skipping elements and eventually getting there. Correct me if I'm wrong, but the count in GetRecordCount is set to the highest-numbered record yet pointed to as you traverse the records. The total number of records is only known after moving past the last record. This is what I was trying to avoid. Thanks again,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
I have never used CRecordset (I use ADO) but there is an SQL statement that you can execute to get the record count and that is COUNT.
SELECT COUNT(*) FROM MyTable WHERE Clause
I don't know how to run SQL statements using CRecordset, so hopefully someone else would like to add to my post. Or probably you know the answer already.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
If one of the columns was a unique identifier, then you could jump right to that record.
As far as counting goes, some DBMSs return the high-water mark, while others return the actual count. You have to experiment with each one.
You could also look at CRecordset::SetAbsolutePosition(), but it is not considered reliable.
|
|
|
|
|
Sorry about the previous post. I thought you were trying to get the record count but you're not. Anyways, to get to the record that you want to, as DavidCrow suggested you could use unique identifiers. However, if you don't have unique identifiers, you can set filters and then the number of records that you have to iterate will be very small. More details you add to the filter, less records you will get.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
[EDIT: Whoops! I used WORD wParam insted of WPARAM wParam (this is not Win16 code)]
I have a list box control in a dialog with notify selected.
Now here is the problem: when I click on a selection the dialogbox receives a notification ( HIWORD(wParam) ) = 0 insted of = 1 (LBN_SELCHANGE). I have used listboxes and comboboxes for years and have always receive the correct value (1). 0 is not even a valid notification code (unless it's undocumented).
Any ideas?
INTP
|
|
|
|
|
I downloaded sample application and the source codes. I tried to run the application but
I couldn't. While I was compiling the codes, I met some problems. First of all psapi.h error.
I dowloaded psapi.h end psapi.lib files and placed include and lib in the folders. But
I read the Q&A part. atlsecurity.h file wasn't appeared. Whe I compiled the codes, I met some errors below.
I use VC6 and Win98 Second edition.
Can you say me how can I compile and the sample? Please describe as possible as simple. Because
I am new in VC6.
w32process.cpp(83) : error C2039: 'GetProcessImageFileName' : is not a member of '`global namespace''
w32process.cpp(83) : error C2065: 'GetProcessImageFileName' : undeclared identifier
w32pSample\w32process.cpp(100) : error C2065: '_alloca' : undeclared identifier
w32pSample\w32process.cpp(100) : error C2440: 'static_cast' : cannot convert from 'int' to 'struct _TOKEN_USER *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
w32pSample\w32process.cpp(395) : error C2039: 'OpenThread' : is not a member of '`global namespace''
w32pSample\w32process.cpp(395) : error C2065: 'OpenThread' : undeclared identifier
w32pSample\w32process.cpp(395) : error C2440: 'initializing' : cannot convert from 'int' to 'void *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Good bye.
|
|
|
|
|
Hi!
anyone here knows where I can find some info/samples (can be online or a book) about developing plugins for Exchange Server?
Thanks!
---------------
Tired of Spam? InboxShield 2.0.2 for Microsoft® Outlook® 2K/2K2/2K3
http://www.inboxshield.com
|
|
|
|
|
http://www.slipstick.com/[^] used to be pretty good. I haven't visited for a while, so I don't know if it has changed.
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
I have an MFC ActiveX control and an MFC application that uses it. I use Visual C++ 6.0 on Windows NT 4.0 SP6.
I recently added a new property and a new method to the ActiveX control. The control compiled, linked, and registered just fine.
Then I went to the application project, regenerated the wrapper class for the control (Project->Add To Project->Components And Controls..., Registered ActiveX Controls), and rebuilt the app successfully...
But when I run the app, it gets COM Type Mismatch errors when it tries to access a property and a method that were already in the control before my modifications!
I compared the .odl file in the ActiveX control project with the previous version from SourceSafe, and the only changes made to the file were the new property and method I added, which my app isn't even trying to use yet.
I compared the wrapper class in my applicaton to the .odl file to make sure the property/method ID's and parameter/return types all match, and they do. I also looked up the DISPATCH_MAP entries for the misbehaving items in the control's source code - they match too.
And yes, I tried a Rebuild All on both projects - no effect.
Does anyone have any idea why these type mismatch errors are occurring or how I can avoid them?
This problem has me completely flabbergasted and my project has ground to a halt as a result. Any information that could help shed light on this problem would be greatly appreciated.
|
|
|
|
|
Is it possible to play sounds (such as MIDI or mp3 files from a console program?
Thanks, Dave
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
|
I'll study the info you sent me John, thanks much
Dave
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|