Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2005, 10:23 AM
Registered User
 
Join Date: Oct 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading hardware parameters from VBA code

Hello.
Does anybody know how can I read the HDD series or some other hardware parameters from within VBA code in MS Access?
If you can help me, thanks a lot.

 
Old October 4th, 2005, 01:44 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Yes, you need to use a WMI query. Here is a basic format I use to gather data about the local hard drive:

Dim strDrive As String
Dim strComputer As String

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive",,48)
For Each objItem in colItems
    intDiskSpace = Int(objItem.Size / 1000000)
Next

strDrive = "C"
Set objWMIService = GetObject("winmgmts:")
Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='" & strDrive &":'")
intFreeSpace = int(objLogicalDisk.FreeSpace / 1000000)
intRem = (intFreeSpace / intDiskSpace)
'STORE THESE HARD DRIVE VALUES
objRecordset("DiskDriveSize") = intDiskSpace
objRecordset("SpaceRemaining") = intFreeSpace
objRecordset("PerCentRemaining") = FormatPercent(intRem, 2)

HTH

mmcdonal
 
Old October 5th, 2005, 01:47 AM
Registered User
 
Join Date: Oct 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:) Thank's!

 
Old October 5th, 2005, 07:55 AM
Registered User
 
Join Date: Oct 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there a way of checking the screen setting of the Clients PC so that you could make the nessassary provisions for Form sizes etc.
Better still - Would it be possible to set the screen settings to 800X600 in VB?

Thanx
Base
 
Old October 5th, 2005, 08:13 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Yes there is. I will look it up.
You don't ever want to change the screen settings of a user, especially to something ugly like 800x600.
Anyway, if you are designing for 800x600, it will show up well enough on anyone's machine since that is the smallest resolution these days.

mmcdonal
 
Old October 6th, 2005, 02:24 AM
Registered User
 
Join Date: Oct 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks - I'll await your reply. My Work PC is set to 1024 X 768 but I battle to see if I set my Home PC or Laptop to the same. So when I move my appication around I notice the diffence and though that it might create problems later with diff Clients. It would be nice to be able to read and write - then I could change the settings on opening and restore on closing. Else I'll stick to your adivce about the 800X600 "standard".

Thanx so far
Base





Similar Threads
Thread Thread Starter Forum Replies Last Post
run query via vba with parameters The_Vicar VBScript 0 April 21st, 2008 06:38 AM
Parameters from SQL to VBA Skan Access VBA 4 October 25th, 2007 06:53 AM
Reading in webpages in standard Excel VBA w_g_day Excel VBA 5 May 24th, 2005 12:44 PM
reading parameters skaya Crystal Reports 0 August 10th, 2004 09:20 AM
Excel2002: Passing parameters from IE to VBA HappyAlex Excel VBA 0 April 6th, 2004 11:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.