open up a file as read-only
-
Is there a way to open up a word document as read-only when it's not a read-only file to begin with. I opened up my file using CreateProcess. Is there a way to do this? Thanks!
-
Is there a way to open up a word document as read-only when it's not a read-only file to begin with. I opened up my file using CreateProcess. Is there a way to do this? Thanks!
CreateProcess()
does not open files !!!!!!! if you want to open a file with the ReadOnly option, you could do this :std::ifstream file("theFile.txt"); // read-only by default
or
fopen("theFile.txt", "r");
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
Is there a way to open up a word document as read-only when it's not a read-only file to begin with. I opened up my file using CreateProcess. Is there a way to do this? Thanks!
Assuming that you meant CreateFile, pass the second parameter as GENERIC_READ. -- Rocky Dean Pulley
-
CreateProcess()
does not open files !!!!!!! if you want to open a file with the ReadOnly option, you could do this :std::ifstream file("theFile.txt"); // read-only by default
or
fopen("theFile.txt", "r");
TOXCCT >>> GEII power
[toxcct][VisualCalc]I tried the following and still won't open up. I want to open it up in MS Word which was why I used CreateProcess. What did I do wrong? Thanks! FILE * pFile; pFile = fopen (filename,"r"); if (pFile!=NULL) { fputs ("fopen example",pFile); fclose (pFile); }
-
I tried the following and still won't open up. I want to open it up in MS Word which was why I used CreateProcess. What did I do wrong? Thanks! FILE * pFile; pFile = fopen (filename,"r"); if (pFile!=NULL) { fputs ("fopen example",pFile); fclose (pFile); }
Is using
ShellExecute()
out of the question?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
-
Is using
ShellExecute()
out of the question?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
No but how is it different from CreateProcess? There seems to be no parameters that specify it as read-only.
-
No but how is it different from CreateProcess? There seems to be no parameters that specify it as read-only.
I see, you are trying to open with word and not with your own program for reading. What you want to do will probably need to use word OLE automation. I would suggest doing some searching for just that, it's not as simple as just executing the program to do this. It's actually not much more code but understanding the concepts is a bit more complex. I haven't done this sort of thing in a long time so I don't know the code off hand, but I'm sure a quick google search will find something. -- Rocky Dean Pulley
-
Is there a way to open up a word document as read-only when it's not a read-only file to begin with. I opened up my file using CreateProcess. Is there a way to do this? Thanks!
-
:laugh: CFile SrcFile; CString SrcFileName="C:\\test.doc"; SrcFile.Open(SrcFileName,CFile::modeRead ,NULL);
I do not want to read the contents of the file. I want to be able to open the file in Microsoft Word or Notepad as read-only.
-
I see, you are trying to open with word and not with your own program for reading. What you want to do will probably need to use word OLE automation. I would suggest doing some searching for just that, it's not as simple as just executing the program to do this. It's actually not much more code but understanding the concepts is a bit more complex. I haven't done this sort of thing in a long time so I don't know the code off hand, but I'm sure a quick google search will find something. -- Rocky Dean Pulley
I found a simpler way. Before opening up the document in Word, I used GetFileAttributes() to get its file attribute. If the returned value is not read-only, I called SetFileAttributes to set it so and then use CreateProcess to open it up within Word. Much simpler. Thanks for your help though.