|
thanks but in the other replies i saw a shell api function to do so...
thanks again
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Its something like this:
std::string GetApplicationDataPath()
{
std::auto_ptr<char> path( new char[MAX_PATH]);
const HRESULT result = ::SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path.get());
if( result != S_OK)
return std::string();
else {
std::string s( path.get());
if( s.at( s.size()-1) != '\\')
s += '\\';
return s + _T("\\MyApp\\");
}
}
The CSIDL_APPDATA defines which of the plethora of system directories you want.
MSDN has them all.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
use:
SHGetSpecialFolderLocation()
Cheers
"Peace of mind through Technology"
|
|
|
|
|
thanks!
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
wait! if i use CSIDL_MYDOCUMENTS then it returns E_INVALIDARG????
help??
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
like this:
LPITEMIDLIST pidl;
HRESULT hr = SHGetSpecialFolderLocation(NULL,CSIDL_MYDOCUMENTS, &pidl);
|
|
|
|
|
thanks,
can u show me snippet of what to do with the pidl later, i read i need to global malloc it then global free it in order to translate it to a string??
thanks
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
see here[^]
maybe it is some helpful to you
|
|
|
|
|
actually this result as well hr=INVALID_ARG.......
help??
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
use CSIDL_PERSONAL
it seem that your problem is same with
here[^]
|
|
|
|
|
10x!
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
Do you want to create a file in the My Documents folder?
This is from the VS 2005 help file:
szPath will contain the path to My Documents.
If you just want the path in szPath, and don't need to create a file, then don't send in the CSIDL_FLAG_CREATE flag.
TCHAR szPath[MAX_PATH];
if(SUCCEEDED(SHGetFolderPath(NULL,
CSIDL_PERSONAL|CSIDL_FLAG_CREATE,
NULL,
0,
szPath)))
{
PathAppend(szPath, TEXT("New Doc.txt"));
HANDLE hFile = CreateFile(szPath, ...);
}
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
10x!
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
hi all
for example if I have
CString sVal = _T("something");
how to assign sVal to a const char * variable ?
const char * pVal = ... ?
thanks
|
|
|
|
|
|
big_denny_200 wrote: const char * pVal = ... ?
Try this
const char * pVal = (LPCTSTR)sVal;
Large cats have been scientifically proven to dream. Among the recurring themes are balls of yarn, mice, and half-blind overweight shackled oryx.
|
|
|
|
|
CString str=_T("Hello");
const char *buffer;
buffer=(const char*)LocalAlloc(LPTR,20);
strcpy((char*)buffer,str);
LocalFree((HLOCAL)buffer);
|
|
|
|
|
Monty2 wrote: Try this
const char * pVal = (LPCTSTR)sVal;
Can I add something?
Using this way we have to be carefull using pVal in WRITE mode: the pointer points to the local CString object!
Hope it helps.
|
|
|
|
|
_Russell_ wrote: Using this way we have to be carefull using pVal in WRITE mode: the pointer points to the local CString object!
Ofcourse
Thanks for the correction.
Large cats have been scientifically proven to dream. Among the recurring themes are balls of yarn, mice, and half-blind overweight shackled oryx.
|
|
|
|
|
const char * pVal = sVal.c_str();
|
|
|
|
|
The other answers won't work in a Unicode build. You need to convert your CString to ANSI to assign it to a char* variable. The quickest way is:
#include <atlconv.h>
{
USES_CONVERSION;
CString sVal = _T("something");
const char* p = T2CA(LPCTSTR(sVal));
}
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hello,
How can I check on which paltform the program is running?
(Such as: windows 2003, NT, 98 etc).
Thanks.
-- modified at 9:34 Monday 8th May, 2006
|
|
|
|
|
Try GetVersionEx[^]
Large cats have been scientifically proven to dream. Among the recurring themes are balls of yarn, mice, and half-blind overweight shackled oryx.
|
|
|
|
|
What are the advantages of unmanaged code over managed code and vice versa?
|
|
|
|
|
acemahesh@yahoo.co.in wrote: the advantages of unmanaged code over managed code and vice versa
Freedom, flexibility, ...
Maxwell Chen
|
|
|
|