How to get Windows path using Qt/C++ -


i trying windows path using qt , c++. below code compiles, not gettting windows folder path in qt. same code works in visual studio 2010

      wchar_t path[max_path];       shgetfolderpath(null, csidl_windows, null, 0, path); 

the below code change seems working:

     int const buffersize = 512;              qscopedpointer<wchar> dirpath(new wchar[buffersize]);      zeromemory( dirpath.operator ->(), buffersize);      shgetfolderpath(null, csidl_windows, null, 0, dirpath.operator ->()); 

there isn't qt function this, but asking achieved reading environtment variable windir:

qstringlist env_list(qprocess::systemenvironment());  int idx = env_list.indexof(qregexp("^windir=.*", qt::caseinsensitive)); if (idx > -1) {     qstringlist windir = env_list[idx].split('=');     qdebug() << "var : " << windir[0];     qdebug() << "path: " << windir[1]; } 

outputs:

var :  "windir" path:  "c:\windows" 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -