WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
What is FASM G
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
Forum Rules Snippets forum rules

In this forum all the registered users may post their snippets of code they whish to share with the WinAsm Studio community following these basic rules:
* Only snippets of code are accepted in the topics of this forum.
* Discussions, suggestions, requests etc. must be posted in the "Discussions" topic.
* Do not post copyrighted material.
Administrators/moderators may edit, move or delete the entries that do not follow the preceding rules.

 

Get Windows OS information, code snippet for getting Windows & shell32 version, screen width, height & resolution.

PhoBos
Quote Post


Extremely Active Member
******

Group: Members
Posts: 273
Member No.: 3
Joined: 12-May 04


Get current Window OS main informations.
CODE

.data
DLLVERSIONINFO2 struct
   info1 DLLVERSIONINFO <>
   dwFlags dword 0
   ullVersion dword 0
DLLVERSIONINFO2 ends

Environement struct
WindowsVersion dword 0; 95&NT4:0; 98&Me:1; 2000&XP:2
ShellVersion dword 0
ScreenSize POINT <>
ScreenBPP dword 0
IsNT dword 0
IsFullScreen dword 0
Environement ends
Config   Environement <>

.code
GetEnvironement proc lpEnvironement:dword
;Initialisation des constantes systeme.
;Permet d'ajuster le code en fonction des différente versions windows.
;Revoie TRUE si ok, FALSE an cas d'erreur OU VERSION WINDOWS TROP ANCIENNE
;ShellVersion contient la version de Shell32 (utile pour la systray par ex..)
;ShellVersion, sauf cas particulier, peut être consideré comme la version d'IE installée
local osvi:OSVERSIONINFOEX
local hinstDll,pDllGetVersion:dword
local dvi:DLLVERSIONINFO
local tmpDC:dword

;On recupère le nombre de bpp du system
invoke GetDC,NULL
mov  tmpDC,eax
invoke GetDeviceCaps,tmpDC,BITSPIXEL
mov  Config.ScreenBPP,eax
invoke DeleteObject,tmpDC

;Taille de l'écran
invoke GetSystemMetrics,SM_CXSCREEN
mov  Config.ScreenSize.x,eax
invoke GetSystemMetrics,SM_CYSCREEN
mov  Config.ScreenSize.y,eax

;Version de Windows...
;On test l'appel avec OSVERSIONINFOEX. Si echec, no recupère une OSVERSIONINFO.
;C'est le cas sous Windows NT 4.0 SP6 et avant.
invoke ZeroMemory,addr osvi,sizeof OSVERSIONINFOEX
mov osvi.dwOSVersionInfoSize,sizeof OSVERSIONINFOEX
invoke GetVersionEx,addr osvi
.if !eax
 mov osvi.dwOSVersionInfoSize,sizeof OSVERSIONINFO
 invoke GetVersionEx,addr osvi
 .if !eax
  return FALSE
 .endif
.endif


;Valeur des versions :
; 0 : Win95 ou NT4
; 1 : Win98 et Win98SE
; 2 : WinMe
; 3 : Win2000
; 4 : WinXP ou Win2003

;Trop ancienne version de Windows
.if osvi.dwMajorVersion <= 3
 return FALSE
.elseif osvi.dwMajorVersion >= 5
; Nickel, on est sous XP ou 2000
 .if osvi.dwMinorVersion
  mov Config.WindowsVersion,4
 .else
  mov Config.WindowsVersion,3
 .endif  

.elseif osvi.dwMajorVersion == 4
 .if osvi.dwMinorVersion == 0
;pffff, on s'traine sous 95 ou NT4
  mov Config.WindowsVersion,0
 .elseif osvi.dwMinorVersion == 10
;bof, c'est du 98
  mov Config.WindowsVersion,1
 .elseif osvi.dwMinorVersion == 90
;bof, c'est du Me
  mov Config.WindowsVersion,2
 .endif
.endif

;Est-on sous NT ou sous du 9X ?
.if osvi.dwPlatformId == VER_PLATFORM_WIN32_NT
 mov Config.IsNT,TRUE
.endif

;Version de Shell32.dll
invoke ZeroMemory,addr dvi,sizeof dvi
;Si on est sur du WinMe+, il faut utiliser DLLVERSIONINFO2 !!!
mov  dvi.cbSize,sizeof DLLVERSIONINFO
invoke LoadLibrary,SZ("shell32.dll")
.if eax
 mov hinstDll,eax
 invoke GetProcAddress,hinstDll,SZ("DllGetVersion")
 .if eax
  mov  pDllGetVersion,eax
;Appel de DllGetVersion
  lea  eax,dvi
  push eax
  call pDllGetVersion  
  .if eax >= 0
   mov eax,dvi.dwMajorVersion
  .else
 ;DllGetVersion non supporté avant v4.71 => v4.00
   mov eax,4
  .endif
  mov  Config.ShellVersion,eax
;invoke ShowDword,Config.ShellVersion
 .else
  mov Config.ShellVersion,0
  return FALSE
 .endif
 invoke FreeLibrary,hinstDll
.endif
return TRUE

GetEnvironement endp

Sponsored Links
PMEmail PosterMSN
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topic

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google