Access VBA: Is there any way to get computer specs

2019-05-26 16:46发布

I'm creating a form in Access that processes millions of lines of data, and takes several hours (depending on your computer). I want to implement a feature that will read the computer specs, such as CPU speed and amount of RAM, and determine how long the process will take.

Is it possible to get the computer specs using VBA?

2条回答
虎瘦雄心在
2楼-- · 2019-05-26 17:11

1) There is this "environ" function that can give you informations on the "computer" environment. It is usually used to get things such as user name or temp folder, but it is said to return the following values:

environ(x): value returned
1 : ALLUSERSPROFILE
2 : APPDATA
3 : CLIENTNAME
4 : CommonProgramFiles
5 : COMPUTERNAME
6 : ComSpec
7 : HOMEDRIVE
8 : HOMEPATH
9 : LOGONSERVER
10 : NUMBER_OF_PROCESSORS
11 : OS
12 : Path
13 : PATHEXT
14 : PROCESSOR_ARCHITECTURE
15 : PROCESSOR_IDENTIFIER
16 : PROCESSOR_LEVEL
17 : PROCESSOR_REVISION
18 : ProgramFiles
19 : SESSIONNAME
20 : SystemDrive
21 : SystemRoot
22 : TEMP
23 : TMP
24 : USERDOMAIN
25 : USERNAME
26 : USERPROFILE
27 : windir 

2) you have some shell functions that can be used to launch external programs and get a value back. In addition to the standard VBA shell function, you also have some interesting things such as this "shell and wait" function.

3) Of course, you can always declare functions from the windows API in your VBA code and use them to get needed values ...

查看更多
做个烂人
3楼-- · 2019-05-26 17:14
登录 后发表回答