|
You may be right I was hoping someone would have a brainwave.
The reason I wouldn't use USE_MYSOMETHING is because it isn't really that simple, that would be the equivalent of one case in a page long block of #if #elif #endif code, not something I'd want to repeat in more than one place. I'm left with using that lump of code to #define yet another symbol e.g. USE_SUFFIXES and then using that. It's what everyone else does but I was hoping to improve on the state of the art
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Matthew Faithfull wrote: It's what everyone else does but I was hoping to improve on the state of the art
You should stick with learning the current state of the art before you decide to try and improve it.
led mike
|
|
|
|
|
Where were you I wonder when I successfully ported Jaakko Järvi's tuple class to MSVC6, 9 months before the Boost developers managed it?
If you don't have anything useful to contribute you should stick to the Soapbox or better yet not post.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Yeah try to prove you know what you are doing by citing some project you did, good one. To late, the cat's out of the bag now.
Matthew Faithfull wrote: you should
What? I should what, take your advice? When hell freezes over dude, when pigs fly, when bears sh*t in the woods, when, wait, well you get the idea.
led mike
|
|
|
|
|
The preprocessor doesn't work like that. It just sees text and has no knowledge of the value of E_IsCool. You'll need to do something like (just the snippets here):
#define E_IS_COOL_VALUE 1
enum { E_IsCool = E_IS_COOL_VALUE };
#if E_IS_COOL_VALUE != 0
|
|
|
|
|
Yes, I realize the preprocessor isn't going to cut it. I wondered if there was any other mechanism to get the compiler to conditionally ignore/notice chunks of code with a similar effect to the preprocessor but during actual compilation. For the moment I've worked round it but in the longer run that's going to mean defining things in multiple places which is not exactly splendid. Anyway you can see how it works out as this is part of what will almost certainly be my next article, the Compiler abstraction library I ranted at Marc Clifton about nearly a year ago, expect it any time in the next 12 months
Thanks.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hello everyone,
On Windows platform, which API could be used to check whether a file is opened (either by other thread or process or even the same thread) or not?
C++ is fine.
thanks in advance,
George
|
|
|
|
|
One such way is with a device driver (like the one created for use with FileMon and Handle).
You can also check out NetFileEnum() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi DavidCrow,
After reading the MSDN document for NetFileEnum, I am confused. The description is,
--------------------
The NetFileEnum function returns information about some or all open files on a server, depending on the parameters specified.
--------------------
Server means? I just want to find all the used (open) files on the local machine. Any ideas or comments?
regards,
George
|
|
|
|
|
George_George wrote: Server means? I just want to find all the used (open) files on the local machine. Any ideas or comments?
servername
[in] Pointer to a Unicode (Windows NT/2000/XP) or ANSI (Windows 95/98/Me) string specifying the name of the remote server on which the function is to execute. The string must begin with \\. If this parameter is NULL, the local computer is used.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks DavidCrow,
But does it relates to my original question? I just want to find whether a local file is opened or not. Any comments?
regards,
George
|
|
|
|
|
George_George wrote: But does it relates to my original question?
Only you can determine if NetFileEnum() will meet your needs.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi DavidCrow,
This function will find all open files... But I only want to find whether a specific file is open or not, file name is known. The NetFileEnum function is fine, but too heavy for me.
I think using OpenFile with exclusive shared mode option is fine. Any comments?
regards,
George
|
|
|
|
|
George_George wrote: I think using OpenFile with exclusive shared mode option is fine. Any comments
That will only tell you if the file is already open with exclusive access. It will not tell you if the file is already open with shared access. AFAIK, there is no user-mode way to tell that, unless David's previous answer can do that (I haven't ever needed to use the Net set of functions).
Judy
modified on Thursday, April 3, 2008 4:19 PM
|
|
|
|
|
Thanks Judy,
I think I should use ::OpenFile() with OF_SHARE_EXCLUSIVE -- the best choice. Right?
regards,
George
|
|
|
|
|
If you want to test every file under scrutiny, yes that will work. I'd try David's enum suggestion if you're looking to get a list.
Judy
|
|
|
|
|
Thanks Judy,
I only need to test for a specific file. I think OpenFile is enough, agree?
regards,
George
|
|
|
|
|
Yes, using OF_SHARE_EXCLUSIVE
|
|
|
|
|
Thanks JudyL_FL,
Question answered.
regards,
George
|
|
|
|
|
George_George wrote: which API could be used to check whether a file is opened
Depends on your definition of "file is opened". An application can be displaying the contents of a file and even allowing the user to edit the contents without having an active file handle to the disk file used to persist the data. In that case there is no API that's going to tell you that, period.
led mike
|
|
|
|
|
Open I can it is used by other thread/process, they may not open the file in exclusive mode, but I need to detect whether it is used (open) or not. Any ideas?
regards,
George
|
|
|
|
|
You can try opening the file in exclusive mode.
onwards and upwards...
|
|
|
|
|
Thanks basementman!
You mean OF_SHARE_EXCLUSIVE mode of OpenFile?
regards,
George
|
|
|
|
|
|
Thanks Hamid,
I looked through the link, does it relates to my original question?
regards,
George
|
|
|
|