nicolac
asked on
How to assign a path of a file to a const WCHAR * or const FSSpec *?
I'm trying to assign the path of a file to either:
const WCHAR *ptr;
or
const FSSpec *optr;
(These are contained in a structure called FILEIN in the header file.)
This is my path I want one of these to point to:
c:\\myfile.txt"
Here is the method that I'm assigning the values in:
int WINAPI Openfile(const FILEIN *fin)
In this method how do I set either ptr or optr to point to the file path?
Thanks :)
const WCHAR *ptr;
or
const FSSpec *optr;
(These are contained in a structure called FILEIN in the header file.)
This is my path I want one of these to point to:
c:\\myfile.txt"
Here is the method that I'm assigning the values in:
int WINAPI Openfile(const FILEIN *fin)
In this method how do I set either ptr or optr to point to the file path?
Thanks :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Then you would do
FILEIN FilDat;
FilDat.ptr = "C:\\MYFILE.DAT";
OpenFile(&FilDat);
except the string in this case is a wide-character string, so you need to isnure you assigning the pointer to a wide character string. If you are using a string literal (like above) you do that by placing a "L" (long) before the string like
FilDat.ptr = L"C:\\MYFILE.DAT";
if you are initializing the pointer to point to a buffer that stores the string (rather than a strign literal), then you need to make sure the buffer is declared a storign wide characters.
Does that help?
FILEIN FilDat;
FilDat.ptr = "C:\\MYFILE.DAT";
OpenFile(&FilDat);
except the string in this case is a wide-character string, so you need to isnure you assigning the pointer to a wide character string. If you are using a string literal (like above) you do that by placing a "L" (long) before the string like
FilDat.ptr = L"C:\\MYFILE.DAT";
if you are initializing the pointer to point to a buffer that stores the string (rather than a strign literal), then you need to make sure the buffer is declared a storign wide characters.
Does that help?
ASKER
Great thats it, thanks :)
ASKER
STRUCTUREBEGIN(FILEIN) /*File Input info*/
#if !defined(MAC)
const WCHAR *ptr; // full path of file to open
#else
const FSSpec *optr; // file to open
#endif
.....
STRUCTUREEND
In the method
int WINAPI Openfile(const FILEIN *fin)
I want to set the value of either
const WCHAR *ptr;
or
const FSSpec *optr;
Does this explain it better?
You said: For example, if the structure has a member called "path" that is a char * pointer to the file path...
This is it: const WCHAR *ptr;