Detect Windows Style

Just starting out? Need help? Post your questions and find answers here.
PyroStrex
User
User
Posts: 61
Joined: Mon Mar 22, 2010 3:08 pm

Detect Windows Style

Post by PyroStrex »

Is there a way i can do this? like If in windows 7, I wanna detect if the users is currently using aero style or the old windows 95 style.
User avatar
idle
Always Here
Always Here
Posts: 5049
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Detect Windows Style

Post by idle »

don't know about the styles but to detect if desktop composition is on you could try this

I don't have vista or win7 so not sure if this is right and you'll probably want to update it to use a prototype

Code: Select all

Procedure DwmIsCompositionEnabled()
  Protected *pfn,Lib,result
  Lib = LoadLibrary_("dwmapi.dll")
  If Lib
     *pfn = GetProcAddress_(Lib, "DwmIsCompositionEnabled") 
      If *pfn
          Result = CallFunctionFast(*pfn) 
      EndIf 
    FreeLibrary_(Lib) 
  EndIf
  
  ProcedureReturn result 
EndProcedure   

Debug DwmIsCompositionEnabled()
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Detect Windows Style

Post by ts-soft »

@idle
your code is wrong :wink:
the result comes not in the returnvalue of function!
here the corrected code with prototype (work on x86, x64, unicode and ascii)

Code: Select all

Prototype DwmIsCompositionEnabled(*pfEnabled)

Procedure DwmIsCompositionEnabled()
  Protected fpIsCompositionEnabled.DwmIsCompositionEnabled
  Protected Lib, result
  Lib = OpenLibrary(#PB_Any, "dwmapi.dll")
  If Lib
    fpIsCompositionEnabled = GetFunction(Lib, "DwmIsCompositionEnabled")
    If fpIsCompositionEnabled
      fpIsCompositionEnabled(@result)
    EndIf
    CloseLibrary(Lib)
  EndIf
  
  ProcedureReturn result
EndProcedure   

Debug DwmIsCompositionEnabled()
greetings
Thomas
User avatar
idle
Always Here
Always Here
Posts: 5049
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Detect Windows Style

Post by idle »

Thanks Thomas, I wasn't paying attention and couldn't test it either to see if it worked.
Windows 11, Manjaro, Raspberry Pi OS
Image
PyroStrex
User
User
Posts: 61
Joined: Mon Mar 22, 2010 3:08 pm

Re: Detect Windows Style

Post by PyroStrex »

Wow.. Thanks for this. I tried it with both style. It changed :D
Post Reply