From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a user folder for serveral languages

Solved!
Go to solution

Hello,

 

I would like to create a .txt data in in the user folder on a computer.

Now I would like to create these data on every system I install the application. When I write the normal path in englisch C:\\Users\\Public\\Documents\\..... I can create the .txt on an english system but I would like to create these data also on a german system. But on these system the path would be in german. Is there a way that I must not translate the path and this works automatic. At the moment I write the path direct into the braces of the variable. I hope I could explane the problem good enought.

 

Best regards

0 Kudos
Message 1 of 7
(3,454 Views)

Read this discussion:

A better way to get AppData location?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 7
(3,439 Views)

I read that article already. I am a little bit lost to this topic.

 

Where do I get the shell32.lib and how do I add it? (I think it is easy but at the moment I do not know the answer)

 

Best regards

0 Kudos
Message 3 of 7
(3,434 Views)

You must install the interface to Win32API (formerly Win SDK): see the discussion linked to understand how to install it (basically you must perform a custom install and select the appropriate module). Be warned that SHGetFolderPath is available in CVI Full release only: if you are running in CVI Base version you cannot access that function. As per the library, depending on the release of CVI you are using it is located in a different folder: see Windows SDK topic in the help (Programmer Reference >> Compiler/Linker Issues >> Calling Windows SDK Functions in LabWindows/CVI)



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 7
(3,427 Views)

Now I have some more questions.

I do not understand the installation you mentioned. Is the Win32API already on my system? 
So I must install this data, then I have the library and I can integrate it into my project or do you mean that I must integrade it in my project like .fp data?

 

Is there a easier way to built my path to the user folder for different systems?

I read about some option for microsoft batch programing that they use something like this in the path %%User%% and so it finds alway the user folder.

 

Best regards

0 Kudos
Message 5 of 7
(3,401 Views)

Windows SDK is not installed by default together with CVI: you must explicitly perform a custom setup and add it to the features to install. See this post from Luis G.

In the Help menu there is a 'Windows SDK' item: I suppose it is grayed out if the SDK is not installed or you receive an error in that case.

Once you have the SDK installed, simply add the library to the project, #include windows.h and set the version marcro as explained some post after the one I linked.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 7
(3,396 Views)
Solution
Accepted by topic author Fasching_K

Thank you your help. I have found a easier method to solve the problem. In C there is the command getenv. With this command you can also search für the APPDATA and then return the path. You can use the parameter (ALLUSERSPROFILE, APPDATA,.....) like in the section "Default Values" on this side "https://en.wikipedia.org/wiki/Environment_variable" and get always the path you want without the Windows SDK. The rest of the program is to create a directory and copy the strings, create the .txt or what else....and so on. You get always the correct path on various windows systems.

 

#include "stdafx.h"

#include <stdio.h>      /* printf */

#include <stdlib.h>     /* getenv */

 

int _tmain(int argc, _TCHAR* argv[])

{

       char* pPath;

       pPath = getenv ("APPDATA");

       printf("Current Path: %s\n", pPath);

       return 0;

}

 

Best regards

Message 7 of 7
(3,384 Views)