|
If I understood u right, you dont want another process to access the file when ur program is using it, to do this use CFile::shareExclusive with the Open operation.
if u open a file while in read-only, u cant write in it unless u clear this attribute, so that ur program crashes.
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Im not sure I understand all you're saying but :-
assuming : - LPCTSTR lpFileName
DWORD dwFileAttributes = GetFileAttributes( lpFileName);
long mask = dwFileAttributes;
if( ! ( dwFileAttributes & FILE_ATTRIBUTE_READONLY))
{
mask = dwFileAttributes | FILE_ATTRIBUTE_READONLY;
if( ! SetFileAttributes( lpFileName, mask))
{
// Flag the error here
return;
}
}
is probably what you're looking for - your program would of course have to remove the readonly flag before it used the file - the suggestion above this is also valid (ie exclusive flag)
'g'
|
|
|
|
|
Hello Garth,
yes, this is that what im looking for!
but need some help again!
Please check this code:
<br />
DWORD dwFileAttributes;<br />
DWORD mask;<br />
<br />
dwFileAttributes = GetFileAttributes(csFileName);
mask = dwFileAttributes;<br />
<br />
if((dwFileAttributes & FILE_ATTRIBUTE_READONLY))<br />
{<br />
mask = dwFileAttributes & FILE_ATTRIBUTE_NORMAL;
if(!SetFileAttribute(csFileName, mask))<br />
{<br />
AfxMessage(csErrorMessage);<br />
}<br />
}<br />
<br />
cMyFile.Open(...);<br />
dwFileAttributes = GetFileAttributes(csFileName);
mask = dwFileAttributes;<br />
if(!(dwFileAttributes & FILE_ATTRIBUTE_READONLY))<br />
{<br />
mask = dwFileAttributes | FILE_ATTRIBUTE_READONLY;
if(!SetFileAttributes(csFileName, mask))<br />
{<br />
}<br />
}<br />
This is what im doing with your response!
Is this right, take a look to my sample please!
Maybe is not the best way, but they do wat i want!
with best regards
break;
|
|
|
|
|
I would have done :-
DWORD dwFileAttributes = GetFileAttributes( lpFileName);
long mask = dwFileAttributes;
if( dwFileAttributes & FILE_ATTRIBUTE_READONLY)
{
long mask = dwFileAttributes & (~FILE_ATTRIBUTE_READONLY);
if( ! SetFileAttributes( lpFileName, mask))
{
// Output Some sort of error here
// Could not make (file) READ WRITE
return;
}
// Good - Output Some Soft of Message here ?
// (file) Is Read/Write
}
not sure if that answers your question
'g'
|
|
|
|
|
Good morning!
yeah, that it's!
With best regards!
break;
|
|
|
|
|
I am trying to repair the Curroupted Ms Access .mdb file.
here i able to get and insert most of the data from the Curroupted file to new created file by using the function defined in MsAccess class msacc9.olb in VC++.
I able to read and inser most of the data but unable to insert image in the OLE data field.
Is there any code or any othe way to do so.
Pls help me realated to this.
Thank You
Nirmal
|
|
|
|
|
|
Is there any way to get wheel mouse to work in the Call Stack Debug window in Visual C++ 6.0?
Wheel mouse works in normal source code windows.
|
|
|
|
|
Do you need to three actions from mouse(L/R/M)?
|
|
|
|
|
How to differentiate which is folder and which is files at run time?
|
|
|
|
|
kiranin wrote: differentiate which is folder and which is files at run time?
See WIN32_FIND_DATA
The first parameter to this has the information about the file/folder attributes.
FILE_ATTRIBUTE_DIRECTORY-The handle identifies a directory.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
hi all,
I need to display the 'Browse For Folder' Dialog window, but I need to place it in a combo box instead of being a popup dialog, so can anybody help with this???
Thanks
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
You can insert your controls to it but for insert it to combobox I dont know why you want to insert it to combobox do you need to folders?
|
|
|
|
|
I dont want to display in a combo box so that it doesnt take much of the dialog area...
do u know how???
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
You can use from CTreeCtrl and see examples for file/folder with CTreeCtrl on codeproject did you see them?
|
|
|
|
|
Hi,
I am trying to develop a socket server which will communicat with Microsoft Office in LAN.
But I don't know even a small bit about socket server. Can anyone help me out? Please Reply as soon as possible.
Thank you.
|
|
|
|
|
You should go to the networking section of codeproject and pickup a begginers tutorial on sockets, its a long way to be discussed in a single post...
Regards,
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Thank u 4 ur reply but cause i m very new in this site i could not reach at the place show by u, can u plz tell me the proper link of it such that i can view the tutorial. Plz.
|
|
|
|
|
|
Thank you for ur kind help and ofcourse fast reply.
|
|
|
|
|
Anyone knows where I can get the errata of <<c++ primer,="" 4th="">>?
If there is no, anyone wants to create it? If so, plz contact me!
P.S.
I have done:
1. There is no on Stanley B. Lippman's website(http://staff.develop.com/slip/) and blog(http://blogs.msdn.com/slippman/).
2. I can't google it.
3. Email to him(slippman@objectwrite.com).
Thanks!
=== Inside Wintel! ===
Who: DollfaceYY (杨洋)
QQ: 55780839
MSN: DollfaceYY@hotmail.com
EMail: DollfaceYY@163.com
URL: DollfaceYY.china-pub.com
|
|
|
|
|
WM_PRINT does not print controls of a dialog box properly
I create dialog boxes in VC++ version 7 using WINDOWS API function calls
I tried to print dialog boxes by sending message WM_PRINT to
dialog window proc. but controls are printed to the top-left corner of paper,
as if all controls have x = 0 and y = 0; nothing seems wrong according
to MSDN. I create dialog boxes by calling functions CreateDialogParamW or
CreateDialogIndirectParamW. I get hDC to printer device by calling PrintDlg or
PrintDlgEx functions width PD_RETURNDC flag set.
Can any one help me?
|
|
|
|
|
Just a suggestion:
Why dont u get the bitmap of your window object and send it to the printer?? it might be easier, although I dont remember how, but I can remember that it is done using DCs.
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Hi,
We made a project of server and client which are connected through sockets in LAN.
Now we have a idea that to implemnt the same project in internet that the client can get access to server through Internet not through Sockets.
I dont know a small bit about internet connectivity.
Can u anyone pls give idea for this?
Whether i have to write the whole project in to a new thing or shall i make a small changes in old project for internet connectivity...
Pl help me out?
Anu
|
|
|
|
|
That depends on your needs. If you want security, you should use Web Services. DCOM and RPC are also possible, but they are only recommeded for trusted boundaries. Also, there are performance issues with these over the internet, since they are more OOP oriented. XML-Webservices can be implemented using the ATL-Server templates, check here :. In any case, there are certain design issues to be considered when stepping from LAN to Internet. Latency is usually much higher, so try to minimize the number of function calls (no chatty interfaces). Try to put as much information as possible into a single transmission. Bandwith is cheap, latency is expensive.
I hope that helps you a little.
|
|
|
|