Page 1 of 1

Detect Windows Style

Posted: Sat Dec 11, 2010 12:53 am
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.

Re: Detect Windows Style

Posted: Sat Dec 11, 2010 2:21 am
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()

Re: Detect Windows Style

Posted: Sat Dec 11, 2010 2:38 am
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

Re: Detect Windows Style

Posted: Sat Dec 11, 2010 4:51 am
by idle
Thanks Thomas, I wasn't paying attention and couldn't test it either to see if it worked.

Re: Detect Windows Style

Posted: Sat Dec 11, 2010 11:45 am
by PyroStrex
Wow.. Thanks for this. I tried it with both style. It changed :D