Perl篇:获取操作系统的信息
1、获取操作系统版本信息
1 use Win32;
2 use strict;
3 ($OS_string, $OS_major, $OS_minor, $OS_build, $OS_id) = Win32::GetOSVersion();
2 use strict;
3 ($OS_string, $OS_major, $OS_minor, $OS_build, $OS_id) = Win32::GetOSVersion();
2、获取系统目录
1 my $systemdir= Win32::GetFolderPath(0x0025) if(Win32::GetFolderPath(0x0025));
在xp系统下$systemdir的变量值为C:\Windows\System32
3、获取Windows目录
1 our $windir = Win32::GetFolderPath(0x0024) if(Win32::GetFolderPath(0x0025));
在本人xp系统下$windir的变量值为C:\WINDOWS
4、获取系统所在的磁盘驱动号
1 our $rootdir= $ENV{SYSTEMDRIVE} if($ENV{SYSTEMDRIVE});
在本人xp系统下$rootdir的变量值为C:,因为我机器操作系统装在C盘
5、获取执行程序当前目录
1 our $currentdir = Win32::GetCwd() if(Win32::GetCwd);
6、获取用户的document文件夹
1 our $alldocuments = Win32::GetFolderPath(0x002e) if(Win32::GetFolderPath(0x002e));
在本人xp系统下, $documents的变量值为C:\Documents and Settings\All Users\Documents
7、获取临时文件夹目录
1 our $tempdir = $ENV{TEMP} if($ENV{TEMP});
8、获取当前用户启动文件夹目录
1 our $mystartup = Win32::GetFolderPath(0x0007) if(Win32::GetFolderPath(0x0007));
9、获取所用用户启动文件夹目录
1 our $allstartup = Win32::GetFolderPath(0x0018) if(Win32::GetFolderPath(0x0018));
10、获取Program Files文件夹目录
1 our $programdir = Win32::GetFolderPath(0x0026) if(Win32::GetFolderPath(0x0026));
11、获取AppData文件夹目录
1 our $myappdata = Win32::GetFolderPath(0x001a) if(Win32::GetFolderPath(0x001a));
12、获取Desktop文件夹目录
1 our $mydesktop = Win32::GetFolderPath(0x0010) if(Win32::GetFolderPath(0x0010));
13、获取当前用户Favorite文件夹目录
1 our $myfavorites = Win32::GetFolderPath(0x0006) if(Win32::GetFolderPath(0x0006));
14、获取所有用户的Favorite文件夹目录
1 our $allfavorites = Win32::GetFolderPath(0x001f) if(Win32::GetFolderPath(0x001f));
15、获取启动菜单文件夹目录
1 our $mystartmenu = Win32::GetFolderPath(0x000b) if(Win32::GetFolderPath(0x000b));
16、获取计算机名称
1 our $computername = Win32::NodeName() if(Win32::NodeName());
17.、获取当前系统登录用户名
1 our $username = Win32::LoginName() if(Win32::LoginName());