-
October 3rd, 2001, 02:03 PM
#1
CFile::Open within an ActiveX ?
I have the following code within an ActiveX control and it crashes the TestContainer every time.
CFile f;
CFileException e;
TCHAR* pFileName = _T("c:\\tree.txt");
f.Open(pFileName, CFile::modeRead | CFile::shareDenyWrite, &e);
The "tree.txt" file is in the "c:\" directory.
Is there another way I should be doing file reading from within an ActiveX control?
Any help would be greatly appreciated.
Thanks. Pete
-
October 3rd, 2001, 02:07 PM
#2
Re: CFile::Open within an ActiveX ?
I forgot to mention the error I get is:
3e6 : "Invalid access to memory location"
-
October 3rd, 2001, 02:08 PM
#3
Re: CFile::Open within an ActiveX ?
use ifstream C++ class, or fread().
Please - rate answer if it helped you
It gives me inspiration when I see myself in the top list =)
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
Member of Russian Software Developer Network http://rsdn.ru
-
June 20th, 2014, 10:54 AM
#4
Re: CFile::Open within an ActiveX ?
Originally Posted by pdcira
I have the following code within an ActiveX control and it crashes the TestContainer every time.
CFile f;
CFileException e;
TCHAR* pFileName = _T("c:\\tree.txt");
f.Open(pFileName, CFile::modeRead | CFile::shareDenyWrite, &e);
The "tree.txt" file is in the "c:\" directory.
Is there another way I should be doing file reading from within an ActiveX control?
Any help would be greatly appreciated.
Thanks. Pete
Shouldn't this line...
TCHAR* pFileName = _T("c:\\tree.txt");
only have one backslash?
TCHAR* pFileName = _T("c:\tree.txt");
Perhaps that would work better?
-
June 20th, 2014, 11:57 AM
#5
Re: CFile::Open within an ActiveX ?
Originally Posted by HarveyURAD
Shouldn't this line...
TCHAR* pFileName = _T("c:\\tree.txt");
only have one backslash?
TCHAR* pFileName = _T("c:\tree.txt");
Perhaps that would work better?
No! \ is the escape char in strings so to actually have a \ in a string you use \\. See http://msdn.microsoft.com/en-us/library/6aw8xdf2.aspx
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
June 21st, 2014, 09:48 PM
#6
Re: CFile::Open within an ActiveX ?
Originally Posted by 2kaud
Ah! You are absolutely correct, my mistake
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|