|
i am working on client server application both are developed on mfc.My problem is that client create a file after writing put it in a directory on server and server is continuously searching that directory and try to open that file but still hold by client.How can i know that particular file is not hold by client.
thank u in advance
|
|
|
|
|
One solution may be sending a parameter when client ends working with file.
Another possibility (but I don't know if that is ok for you) is to use the "share priviliges" flags of the file. You can create the file to be used only by one application or by more as you want.
Another one would be create another empty file that just hold the name of the first one + _busy or something like that, and deleting that sec file after ending the work with the first one.
P.S. there must most probably be better solutions, my knowledge is limited, this is just a logic think.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
modified on Wednesday, December 19, 2007 4:22:20 AM
|
|
|
|
|
Nalek came up with some solutions.
Another one... Write to file AAAA.aaa, then when you're done with it, close it, and rename it to BBBB.bbb, and the server can then catch that file.
I hope the server is not in a loop continouusly checking for the file - your users won;t thank you for that. I trust you're using FindFirstChangeNotification etc for this job.
Iain.
|
|
|
|
|
Iain Clarke wrote: Nalek came up with some solutions.
Another one... Write to file AAAA.aaa, then when you're done with it, close it, and rename it to BBBB.bbb, and the server can then catch that file.
I suppose that is an irony to say my solutions suck. For next times, I prefer a simple "this is bad, is better that". I know I am limited, but I try and from corrections like yours
Iain Clarke wrote: I trust you're using FindFirstChangeNotification etc for this job
I learn too.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Iain Clarke wrote: I hope the server is not in a loop continouusly checking for the file...
That's what his "server is continuously searching that directory" comment is implying.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Can we restart the system programatically?
Can you show me tha way?
Thank you.
Saadhinchaali
|
|
|
|
|
The following is from MSDN :
BOOL WINAPI InitiateSystemShutdown(
__in_opt LPTSTR lpMachineName,
__in_opt LPTSTR lpMessage,
__in DWORD dwTimeout,
__in BOOL bForceAppsClosed,
__in BOOL bRebootAfterShutdown
);
Initiates a shutdown and optional restart of the specified computer.
To record a reason for the shutdown in the event log, call the InitiateSystemShutdownEx function.
However, note the following :
To shut down the local computer, the calling thread must have the SE_SHUTDOWN_NAME privilege.
To tweak privileges, use OpenProcessToken(), LookupPrivilegeValue(), AdjustTokenPrivileges().
Best of luck,
Bio.
|
|
|
|
|
|
Thank you so much guys.
Saadhinchaali
|
|
|
|
|
You're welcome.
|
|
|
|
|
This is my code for the Getting the special folder path, which is not working on the Windows 98. ( Same application works well on the Windws XP Pro.
1. Is anything remainig in my code?
2.any better way to do this task?
I have also tried following function on Windows 98, but still unable to get proper result.
SHGetSpecialFolderLocation
SHGetFolderPath
SHGetFolderLocation
Code =>
<br />
BOOL bRet ; <br />
char spath[MAX_PATH];<br />
bRet = SHGetSpecialFolderPath(NULL, (LPSTR)spath, CSIDL_PROGRAM_FILES, 0); <br />
AfxMessageBox(spath);
|
|
|
|
|
According to the MSDN[^] CSIDL_PROGRAM_FILES is not supported before version 5.0 (Windows XP)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Then how to get the Program files and other folder which are not supported in that version?
|
|
|
|
|
How about this.
You're program was probably installed there?
If so, use GetModuleFilename() to figure out where you run from and therefore where program files are.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
According to the MSDN-page for SHGetFolderPath
"[SHGetFolderPath] is a superset of SHGetSpecialFolderPath, included with earlier versions of the Shell. On systems preceeding those including Shell32.dll version 5.0 (Windows Millennium Edition (Windows Me) and Windows 2000), SHGetFolderPath was obtained through SHFolder.dll, distributed with Microsoft Internet Explorer 4.0 and later versions. SHFolder.dll always calls the current platform's version of this function. If that fails, it will try to simulate the appropriate behavior. SHFolder.dll continues to be included for backward compatibility, though the function is now implemented in Shell32.dll."
And CSIDL_PROGRAM_FILES is specifically mentioned as supported. That sounds as if this would work with Win98!
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Another tip (from David Crow, actually):
Look at your environment variable ProgramFiles .
Is it there? Does it point to something reasonable?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Take the driver letter returned from GetSystemDirectory() or GetWindowsDirectory() , and append "\\Program Files" to it.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hmmmpf.
IIRC, Windows 98 did localize its program path.
In Germany, we already had "\\Programme".
But I do not have a Windows98 ready to check it.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
What is the value of your ProgramFiles environment variable?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have no Win98 bootable here, but I remember hassles with the translation back then.
Here in the company I am currently working on a US WinXP with German locale settings. So I couldn't even tell for German WinXPs...
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
I just looked it up for a German W2K:
There its pointing to "C:\Programme"
Not that this does help the OP, though.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
jhwurmbach wrote: Not that this does help the OP, though.
Why not?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
He asked specifically for Win98.
That is software-archeology!
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
jhwurmbach wrote: He asked specifically for Win98.
Does the ProgramFiles environment variable exist on that OS?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
As I said, I don't have Win98 bootable here.
All I have are German WinXP and W2k, and both have %ProgramFiles, and it points to "C:\Program Files"
But MSDN says:
"SHGetFolderPath is a superset of SHGetSpecialFolderPath, included with earlier versions of the Shell. On systems preceeding those including Shell32.dll version 5.0 (Windows Millennium Edition (Windows Me) and Windows 2000), SHGetFolderPath was obtained through SHFolder.dll, distributed with Microsoft Internet Explorer 4.0 and later versions. SHFolder.dll always calls the current platform's version of this function. If that fails, it will try to simulate the appropriate behavior. SHFolder.dll continues to be included for backward compatibility, though the function is now implemented in Shell32.dll."
And CSIDL_PROGRAM_FILES is specifically mentioned as supported. That sounds as if this would work with Win98!
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|