c++ - windows里的短路径是个什么写法?
大家讲道理
大家讲道理 2017-04-17 13:29:09
0
3
563
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
巴扎黑

This is not a short path, it is an environment variable.
Using variables is of course more general. Hard-coded things can only work on your own machine.

Take the python you mentioned as a small example. You wrote a clear.py script file, whose function is to clean up the user's system temporary folder.
If you don’t use variables, you might write it like this (pseudocode)

del C:\Users\adminstrator\AppData\Local\Temp\*.*

A script like yours cannot be run on other people’s machines. First of all, you need to know the currently logged-in user name, and you have to call the API to know the user’s Temp folder path (maybe on the D drive or E drive) Possibly)

But if you use the system’s default %TEMP% variable, you don’t need to worry about it

del %TEMP%\*.*
Ty80

To enhance program portability. For example, whether your Windows is installed on the C drive, D drive, or some X drive, the program can be accessed through a short path without the need to hard code the specific path.

伊谢尔伦

The actual installation directories of different computers are not necessarily the same. For example, some of the same software is installed on the c drive and some on the d drive. The actual location is saved through such an environment variable. The program only needs to access the environment variable. , which can enhance the portability of the program.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!