Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gettings System Make and Model

Status
Not open for further replies.

LordJC

Programmer
Aug 6, 2009
5
US
I am trying to make a program that is gathering diagnostic information from the computer and detect which Anti-Malware program they have on the computer. The problem I am running into is trying to figure out how to get the system manufacturer and system model. I know this info is within the WMI but I'm not sure how to retrieve it.
 
This is what I got in mind, after reading your ask:

TApplication and Sysutil.h are the places where I would search to get info about the system.



C++ Builder 5 has in his folder "Examples" a procViewer demo. I think it provides the info you will like to receive.

You could use Win Api, enumerating "threadprocesses" to find out what's running on your pc.


 
I actually did look through the examples for any way to hook the script into the WMI. The example you referenced seems to only be able to get running processes. I'm still looking through the Sysutil.h for an answer.
 
I made a search on internet :"WMI and now I understand better your problem. :))

I tried to write an example. I succeeded to compile one, but running the program I don’t succeeded to have an connection with the server (dll)

On my computer I found in the map: C:\WINDOWS\system32\wbem 2 tlb files: Wbemads.tlb and Wbemdisp.tlb

I opened a package project and imported those 2 type library.
After I built the package I got 9 new wrappers-components.

I opened a new vcl project and dropped TSWbemNamedValueSet and TSWbemLocator. on the Form.

With the help of a demo code, that I found on msdn; I tried to write an program, that should list the running processes

I could run the code but I got the error that I wasn’t connected to the service.

I don’t known if this is the wright way, but this is the way I should start.

Success whished
 
It doesn't necessarily have to be from WMI. From what I have read and heard, telling C++ to query information let alone connecting to it is somewhat troublesome. Is there anyway to pull the information directly from the computer using C++. For example from the BIOs where the information is truly stored? I searched the sysutils.h file for answer and couldn't really find an answer.
 
I think you should ask your question in the WinApi forum.
WinApi is the way to get all the information about your computer.
I can not guess how many functions are available.
The way to explore those function is using impdef.
If you have C++Builder 5, use the wintools. It is available in the "example" map: "WinTools"

Run wintools
Open the impdef tab
Browse for kernel32.dll (this is the library for system services)
change the command: impdef kernel32.def kernel32.dll
to: impdef -a kernel32.def kernel32.dll

next you find an extract of the list:
_GetCurrentDirectoryA = GetCurrentDirectoryA;GetCurrentDirectoryA _GetCurrentDirectoryW = GetCurrentDirectoryW;GetCurrentDirectoryW
_GetCurrentProcess= GetCurrentProcess ; GetCurrentProcess
_GetCurrentProcessId = GetCurrentProcessId;GetCurrentProcessId
_GetCurrentThread = GetCurrentThread; GetCurrentThread
_GetCurrentThreadId = GetCurrentThreadId; GetCurrentThreadId

You can do that for each WinApi dll (not each dll is an Win Api Dll)

Before you can use those functions in C++Builder you need to learn
how to use those functions in an C++ program, which are the parameters, wich library you need and wich header file.

Learning Win Api can not explained in some lines. It will be hard working and study.

succes.
 
I kind of solved my dilemma. I know that in vbscript its easy to query information from wmi. So I cheated a little and have my C++ app create a vbs text file, run it, it queries the WMI and exports the data to a text document where my C++ program imports that text document and puts the info into its respect variables. Makes it kind of cheap but nice and easy.
 
You might run into big problems when trying to do this on Windows Vista. If the user has User Account Control (UAC) turned on, the ability to gather this information might be blocked.

Jeff
_______________________________________
Up to 45% off PC hardware at
 
That shouldn't be an issue, the main executable is marked to only be ran as administrator on Vista so when it runs the script, it gets the admin privileges as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top