The following code examples demonstrate how to
perform certains tasks associated with the
GetSystemInfo ActiveX
control.
Registering the GetSystemInfo ActiveX control
GetSystemInfo ActiveX is an ActiveX control and in order to
be used by the application, an ActiveX control must
be registered on the machine where it will be used.
The
GetSystemInfo ActiveX control is automatically registered
when you install the
GetSystemInfo ActiveX package. However, if
you will ever need to register or unregister the
GetSystemInfo ActiveX control manually you can do that by simply
using the regsvr32 command in Windows Command
Prompt. For example, to register the
GetSystemInfo ActiveX
control (GetSystemInfo.dll) you could use the
following command:
regsvr32 GetSystemInfo.dll
|
Make sure you specify the full path for
GetSystemInfo.dll when using the regsvr32
command. GetSystemInfo.dll is located in your
GetSystemInfo ActiveX installation folder, usually the
C:\Program Files\Get System Info ActiveX\bin folder.
Similary, if you wish to manually unregister the
GetSystemInfo ActiveX control (GetSystemInfo.dll) you
could use the following command:
regsvr32 /u GetSystemInfo.dll
|
Creating the GetSystemInfo ActiveX control
Once you have the GetSystemInfo ActiveX control installed on
the machine where you will be using it, you are
ready to create the GetSystemInfo ActiveX control in your
application code. How you will create the GetSystemInfo ActiveX
control (or any other ActiveX control) in your
application depends on the development environment
(and programming language) you are using. Generally,
there are 2 approaches: you are either allowed to
add the GetSystemInfo ActiveX control to the toolbox where your
other controls are located in your development
environment and then simply use the GetSystemInfo ActiveX
control like any other control already on the
toolbox, or you need to create the GetSystemInfo ActiveX control
programatically in order to use it in your code.
For example, if you are using Microsoft Visual
Studio Visual Basic to build your Windows application you can
simply add the GetSystemInfo ActiveX control to the toolbox by
righ-clicking the toolbox and choosing Choose
Items... from the context menu. A dialog box
will appear where you should click the COM
Components tab and then in the list put the
checked mark beside SysInfo Class entry
and click the OK button. The GetSystemInfo ActiveX control will
appear on the toolbox from where you can drag it to
the form and start using it by setting its
properties and calling its methods from your code.
Here we use create a project named GetHddSerialNumberDemo with Visual Basic 2008, as follow:
Figure 1. create a new project
Figure 2. right-clicking on the
toolbox and choose choose items....
Figure 3. choose GetSystemInfo ActiveX from the list.
Figure 4. GetSystemInfo ActiveX on the toolbox
Figure 5. Adding the GetSystemInfo ActiveX control
to the Visual Studio toolbox.
Now we add a textbox and a button on to the form, change button's caption to Get hard disk serial number(hdd number).The finished Renderings as follow:
Add follow code segment to the Get hard disk serial number button clicked event handler:
TextBox1.Text = AxSysInfo1.GetDiskSerialNum(0)
Start up the program and click the Get hard disk serial number button, look:
|