|
|
Many thanks, that solved the problem. I had looked at DeviceIoControl() but my (outdated) Winioctl.h did not have is call param!
Regards
Andy
|
|
|
|
|
Hey Andy,
Great to hear that it solved your problem. Yeah... I am also using old Microsoft compilers such as VC6/2005 and I have them all installed side-by-side. You should probably keep an updated 'Platform SDK'... which I believe has been renamed to 'Windows SDK'.
Somebody should probably post an article or tip that shows which SDK updates are compatible with each compiler... I am somewhat surprised that Microsoft does not have such a document. You cannot use many of the more recent 'Microsoft SDK' packages with older MS compilers. I have actually been successful with modifying some of the later SDK headers to make it work with older compilers... but that's probably not encouraged or supported.
Anyway, good luck with your project. (Why are you working the day after Christmas?)
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David
I was a bit suprised to receive your last mail. Most people don't bother to 'follow up'.
Yes, all my stuff belongs in a museum. But, funds don't permit upgrades yet. I'm now in my 60's after over forty years in computing, single, live alone - hence working over the holidays.
A couple of questions. In your solution you gave this format "\\\\.\\\\%c:". I assume this to be for extended filepath string length support. But the documenation with my old compiler has it as "\\\\.\\"
Is this the norm for extended length support? Users are bound to come up super long path names.
Also, in my application I also access network drives. Does the "\\\\pc name\\drive name\\" give this extended length support?
Regards
Andy Belton
|
|
|
|
|
Hey Andy,
Andy Belton wrote: A couple of questions. In your solution you gave this format "\\\\.\\\\%c:". I assume this to be for extended filepath string length support. But the documenation with my old compiler has it as "\\\\.\\"
Actually the documentation to your old compiler is correct... for opening the device namespace you need to prepend "\\.\" which as you know escaped looks like "\\\\.\\"
I have no idea why my old code snippit from 2009 contains an extra backslash. I write alot of these code snippits impromptu... so some of them may contain typos or minor flaws. I can tell by looking at the above code snippit that I wrote it on the spot... because it doesn't return a value... or modify any variables being passed into the function. It is just enough to illustrate the idea and help the developer move forward.
Andy Belton wrote: Is this the norm for extended length support? Users are bound to come up super long path names.
I believe that you are referring to the Unicode version of the CreateFile Function[^]... you would need to prepend a L"\\?\" which escaped for c++ looks like L"\\\\?\\"
Andy Belton wrote: Also, in my application I also access network drives. Does the "\\\\pc name\\drive name\\" give this extended length support?
Yes, you can access files over the network with a path greater than 260 characters however you will need to use the Unicode version of CreateFile function[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David
Sorry to bug you again.
My application was finished and put out for field trials. Yup - it hit a couple of problems (well quite a few actually). Most were trivial to solve. However, I am stuck with two, both related (one directly the other indirectly) to my original question.
To help understand the setup, the application is XP platorm based and used primarily at the client office. Howeverm the application also needs to be used in the field (litteraly). So the client wanted the facility to copy work data files on to a second drive that could then be sent out to 'engineers' working in the field who could then interogate them on whatever they have there.
The reason for getting the Physocal drive info wsa to ensure that the files were not written to the same physical drive. After writing, the target drive is removed and sent out. (The drive can be internal or external). (That is about the limit as to what I can disclose for security reasons).
In my code, I used your solution to obtain the physical drive information. I compare the DriveNumber and PartionNumber numbers to enure they are different drives. This is fine. But I think that I should also be check which controller is being used as I could be blocking a drive that is actually on a different controller.
So, Question 1 - How do I determine the drive controller? I have spent some time searching both MSDN and CodeProject and have not found an obvious answer. I think what I need to find are the four parameters as used in boot.ini to select the boot operating system.
Now for the indirectly related problem. In practice, the client is using whatever hard drive comes to them from another source. Normally this drive is NTFS formated but some times it is FAT formated. I have no control over this and neither does the client. Out in the field I am using the file modified date from GetFileInformationEx(). This is because all files are loaded to be shipped out but, only those that have a later date to those exisiting in the field are used. However, we are getting problems with file dates.
It appears that if you copy a file from NTFS to a FAT file system the date can change. The FAT system does not store the milliseconds, instead the time is rounded up. I could deal with this if it were consistant but, I have seen a direct file copy between two drives and the times have been different by as much as five minutes! In one instance, I actually witnessed the file date being two minutes ahead of the current time! Any thoughts on this one? Please?
So, Question 2 - how can I ensure a consistant date record on a FAT drive? I do detect the drive file system and display this to the user.
Best regards
Andy Belton
|
|
|
|
|
I'm using the stringstream and the operator << receiving data from a input string, like this:
stringstream ss;
ss.clear();
ss.str("");
ss << inputString;
-------------
string outputString = ss.str();
The string is big and contains white spaces, etc.
Sometimes the "outputString" string reflects the entire inputString, sometimes it's truncated until it reaches a white space...in the same project.
Why it happens ? Is there any way\flag to reset any iostream data processing ?
Thanks for any help.
|
|
|
|
|
- Can you give an example of a failing input string?
- You don't need these lines - the stringstream will be empty on cosntruction:
ss.clear();
ss.str(""); - Does using an ostringstream help (I doubt it)?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Problem solved using the .str() method, I finally could figure out a way to specialize my templates and use the unformated version with strings.
Anyway, thanks a lot for your valuable tips.
|
|
|
|
|
Hey, I'm doing sockets programming. Pretty much new to it.
The application is a Windows Service, in its ServiceMain() function I call CAsyncSocket's Listen() method, to listen for client connections. But after it starts listening for connections, it'll return and the ServiceMain() function will return and the service is stopped.
What I want to do with this is that, wait until a specific event occurs say WM_QUIT, till than listen for connections. How to do it?
void CNTService::ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
{
m_Server.StartListening();
}
I'm okay with mixing Win32 and MFC, so if it can be done in Win32 please do tell me too
|
|
|
|
|
Ahmed Manzoor wrote: What I want to do with this is that, wait until a specific event occurs say WM_QUIT
Does the service have a window (and associated window queue) on which to listen for window messages? Doubt it...
Instead, use a Win32 IPC event object[^] with a name specific to your service (hint: use an ASCII representation of a UUID to get a unique name) and wait on that with WaitForSingleObject[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
But, won't that block the thread and everything will stop!
|
|
|
|
|
Quite true - I was thinking of the other sort of asynchronous IO that uses APCs (but that wouldn't work with WaitForSingleObject - it would need WaitForSingleObjectEx). OK. So, you need a window message pump to handle blocking for you...which is actually something that CSocket provides - whioch leads to the question - why not use CSocket instead of CAsyncSocket? I can't see any advantage to CAsyncSocket if you're only using one socket....
Anyway - to see how to block and process socket notifications, have a look at the CSocket message loop in CSocket::ProcessAuxQueue, which is in sockcore.cpp in your MFC source directory (that's C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc for me).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Okay, thanks I'll take a look at the source. Its not that I'm using only one socket . I'll add support for more connections, but later. I only need blocking for listening and everything else asynchronous.
I guess, I'll have to kick-off some threads. Any good strategy for using blocking listening and non-blocking I/O, MULTITHREADEDly
|
|
|
|
|
Hi,
I wanted to get the path of Recycle Bin in vista. But when i used
SHGetFolderPath with CSIDL_BITBUCKET , it returns E_FAIL.
how can i get the path of Recycle bin in Vista.
thanks
Nitheesh
Jose Jo Martin
http://www.simpletools.co.in
|
|
|
|
|
The Recycle Bin isn't a real folder - it's a virtual folder that aggregates the recycle bin folders from all drives that have them. Look at the documentation[^]:
CSIDL_BITBUCKET (FOLDERID_RecycleBinFolder)
The virtual folder that contains the objects in the user's Recycle Bin.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
While Stuart is correct that the Recycle Bin is considered a virtual folder... copies of the files and the INFO/INFO2 database are stored in multiple physical locations on mounted disk drive volumes.
Raymond Chen described a method for determining whether a folder is part of the recycle bin:
How can I tell that a directory is really a recycle bin?[^]
As far as I know..all folders with COM class identifier CLSID_RecycleBin have always been created in the root of the volume. So in theory you would need to enumerate all folders in the volume root directory and use Raymond's function to determine if they are part of the recycle bin.
Best Wishes,
-David Delaune
|
|
|
|
|
So...I guess the best response to the OP would have been 'why do you want to do that? Because if you tell us what you really want to do, we can probably give you a better answer...'.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
This seems to be a recurring theme here on codeproject.com where a majority of the questions are poorly formed. When I determine that the author of the post does not know enough about the subject to properly form a question I try to include educational links and a brief summary in my comments to avoid future questions and elongated threads.
Best Wishes,
-David Delaune
|
|
|
|
|
Randor wrote: This seems to be a recurring theme here on codeproject.com
Not just on CP - at work, I'm often asking people 'and your real question is???'
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi David,
Sorry for not describing what i am actually want to do. Here is my problem.
I am doing a project in which i wanted to show the user the files in Recycle bin so that they can make sure that no necessary files are getting deleted in a mistake from the file system. And i am programmatically clearing the Recylcle bin using the API SHEmptyRecycleBin(). So when the user click on button with Caption "Open Recycle Bin" i need to show them with the files in it.
thanks
Nitheesh.
Jose Jo Martin
http://www.simpletools.co.in
|
|
|
|
|
Nitheesh George wrote: when the user click on button with Caption "Open Recycle Bin" i need to show them with the files in it.
A codeproject search provided this example:
How to programmatically use the Recycle Bin[^]
Best Wishes,
-David Delaune
|
|
|
|
|
> Raymond Chen described a method for determining whether a folder is part of the recycle bin
Very bad "method".
(and avoid this poor blog (plenty of wrong notions, not professional at all..))
|
|
|
|
|
I know that sending WM_CLOSE or WM_DESTROY or WM_QUIT can destory a window created by other thread.
But this is not working when the target window is child window(With WS_CHILD Style, like property window in SDI).
[My Question is]
Can I destory other thread's child window?
If I can, please give me some advise about how to do it.
|
|
|
|
|
Did u open the thread with full access permission?
Величие не Бога может быть недооценена.
|
|
|
|