Perl篇:获取操作系统的信息

1、获取操作系统版本信息

1  use  Win32;
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());

 

转载于:https://www.cnblogs.com/royenhome/archive/2010/07/21/1782019.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值