VBA/Excel/Access/Word/Windows API/Window Installation

Материал из VB Эксперт
Версия от 15:48, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Get system temp directory

   <source lang="vb">

Type MEMORYSTATUS

  dwLength As Long
  dwMemoryLoad As Long
  dwTotalPhys As Long
  dwAvailPhys As Long
  dwTotalPageFile As Long
  dwAvailPageFile As Long
  dwTotalVirtual As Long
  dwAvailVirtual As Long

End Type Type SYSTEM_INFO

  dwOemID As Long
  dwPageSize As Long
  lpMinimumApplicationAddress As Long
  lpMaximumApplicationAddress As Long
  dwActiveProcessorMask As Long
  dwNumberOrfProcessors As Long
  dwProcessorType As Long
  dwAllocationGranularity As Long
  dwReserved As Long

End Type Declare Function abGetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long Public Const MAX_PATH = 160 Sub GetSysInfo()

   Dim intMousePresent As Integer
   Dim strBuffer As String
   Dim intLen As Integer
   Dim MS As MEMORYSTATUS
   Dim SI As SYSTEM_INFO
   strBuffer = Space(MAX_PATH)
   intLen = abGetTempPath(MAX_PATH, strBuffer)
   Debug.Print "TempDir" & Left(strBuffer, intLen)

End Sub

</source>
   
  


Get temp folder file path

   <source lang="vb">

Private Declare Function GetTempPath Lib "kernel32.dll" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal Buffer As String) As Long Public Sub Test()

 Dim Buffer As String * 255
 Call GetTempPath(255, Buffer)
 Debug.Print Buffer

End Sub

</source>
   
  


Get Window Installation Path

   <source lang="vb">

Type MEMORYSTATUS

  dwLength As Long
  dwMemoryLoad As Long
  dwTotalPhys As Long
  dwAvailPhys As Long
  dwTotalPageFile As Long
  dwAvailPageFile As Long
  dwTotalVirtual As Long
  dwAvailVirtual As Long

End Type Type SYSTEM_INFO

  dwOemID As Long
  dwPageSize As Long
  lpMinimumApplicationAddress As Long
  lpMaximumApplicationAddress As Long
  dwActiveProcessorMask As Long
  dwNumberOrfProcessors As Long
  dwProcessorType As Long
  dwAllocationGranularity As Long
  dwReserved As Long

End Type Declare Function abGetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long Public Const MAX_PATH = 160 Sub GetSysInfo()

   Dim intMousePresent As Integer
   Dim strBuffer As String
   Dim intLen As Integer
   Dim MS As MEMORYSTATUS
   Dim SI As SYSTEM_INFO
   strBuffer = Space(MAX_PATH)
   intLen = abGetWindowsDirectory(strBuffer, MAX_PATH)
   Debug.Print "WindowsDir" & Left(strBuffer, intLen)

End Sub

</source>
   
  


Get Windows System Path

   <source lang="vb">

Type MEMORYSTATUS

  dwLength As Long
  dwMemoryLoad As Long
  dwTotalPhys As Long
  dwAvailPhys As Long
  dwTotalPageFile As Long
  dwAvailPageFile As Long
  dwTotalVirtual As Long
  dwAvailVirtual As Long

End Type Type SYSTEM_INFO

  dwOemID As Long
  dwPageSize As Long
  lpMinimumApplicationAddress As Long
  lpMaximumApplicationAddress As Long
  dwActiveProcessorMask As Long
  dwNumberOrfProcessors As Long
  dwProcessorType As Long
  dwAllocationGranularity As Long
  dwReserved As Long

End Type Declare Function abGetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long Public Const MAX_PATH = 160 Sub GetSysInfo()

   Dim intMousePresent As Integer
   Dim strBuffer As String
   Dim intLen As Integer
   Dim MS As MEMORYSTATUS
   Dim SI As SYSTEM_INFO
   strBuffer = Space(MAX_PATH)
   intLen = abGetSystemDirectory(strBuffer, MAX_PATH)
   Debug.Print "SystemDir" & Left(strBuffer, intLen)

End Sub

</source>