PDA

View Full Version : Delphi version of Visual Basic's GetObject()



skippyj777
06-23-2001, 02:03 PM
I would like to check the amount of video memory present on the video card. Here is the Visual Basic code that accomplishes this:


Dim controllers As Object
Dim controller As Object
Dim ram As Variant
Dim caption As Variant

Set controllers = GetObject("WinMgmts:").InstancesOf("Win32_VideoController")
MsgBox "Retrieved Win32_VideoController collection."

For Each controller In controllers
caption = controller.caption
If IsNull(ram) Then
MsgBox "Caption returned Null!"
Else
MsgBox "Caption = " & CStr(caption)
End If
ram = controller.AdapterRAM
If IsNull(ram) Then
MsgBox "AdapterRAM returned Null!"
Else
MsgBox "AdapterRAM = " & CStr(ram)
End If
Next


My problem is getting the "controllers" object. I cannot figure out how to do this. I have tried CreateOleObject(), CreateObject(), and GetActiveObject() in various ways and none of them work. How does Visual Basic's GetObject() work, and how can I create a Delphi version of it?

-Josh

skippyj777
06-23-2001, 02:04 PM
Of course, if there is a better way to get the video card RAM size (besides using DX) then I am open to ideas.

-Josh

06-23-2001, 06:47 PM
If you just want a estimation can you use glGetIntegerv(GL_MAX_TEXTURE_SIZE,...)

For a better answer is a texture proxy available. From the red book:

"Example 9-2 demonstrates how to use the texture proxy to find out if there are enough resources to create a 64 64 texel
texture with RGBA components with 8 bits of resolution. If this succeeds, then glGetTexLevelParameteriv() stores the
internal format (in this case, GL_RGBA8) into the variable format.
Example 9-2 : Querying Texture Resources with a Texture Proxy
GLint format;
glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA8,
64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0,
GL_TEXTURE_INTERNAL_FORMAT, &format);"

skippyj777
06-24-2001, 08:15 AM
I need an estimation rounded to the nearest megabyte, such as 8 MB, 12 MB, or 32 MB. The value should be the amount of RAM present on the hardware, not how much is available for use.

-Josh

06-24-2001, 10:30 PM
The texture proxy will give you that. See the red book.

skippyj777
06-27-2001, 12:42 PM
I don't have access to the Red Book. Do you have a link, or would you mind posting the relevant excerpt?

-Josh