Windows 7 here we come

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Windows 7 here we come

Post by RASHAD »

Windows 7
Set Alwayes show all icons and notifications on taskbar PROGRAMMATIC
Tested x86/x64

Code: Select all

Global GetHandle.l ,hKey.l ,lType.l ,lpcbData.l ,lpData.s ,lReturnCode.l ,lhRemoteRegistry.l ,lpDataDWORD.l

Procedure.l GetValue(topKey, sKeyName.s, sValueName.s, ComputerName.s)
   Shared GetValue.s
   lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry) 
   GetHandle = RegOpenKeyEx_(lhRemoteRegistry, sKeyName, 0, #KEY_READ, @hKey)              
   If GetHandle = #ERROR_SUCCESS 
       lpcbData = 255 
       lpData = Space(255)
       GetHandle = RegQueryValueEx_(hKey, sValueName, 0, @lType, @lpData, @lpcbData)                
                   If GetHandle = 0 
                       GetValue = Left(lpData, lpcbData - 1) 
                   Else 
                       GetValue = "" 
                   EndIf
   EndIf 
   RegCloseKey_(hKey) 
   ProcedureReturn GetHandle 
EndProcedure 

   
Procedure.l SetValue(topKey.l, sKeyName.s, sValueName.s, vValue.s, lType.l, ComputerName.s)
  If ComputerName = "" 
    GetHandle = RegOpenKeyEx_(topKey, sKeyName, 0, #KEY_ALL_ACCESS, @hKey) 
  Else 
    lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry) 
    GetHandle = RegOpenKeyEx_(lhRemoteRegistry, sKeyName, 0, #KEY_ALL_ACCESS, @hKey) 
  EndIf 

  If GetHandle = #ERROR_SUCCESS 
    lpcbData = 255 
    lpData = Space(255) 
        GetHandle = RegSetValueEx_(hkey, sValueName, 0, #REG_SZ, @vValue, Len(vValue) + 1)
    RegCloseKey_(hkey) 
    Error = 1 
    ProcedureReturn Error 
  Else 
    MessageRequester("Error", "An Error occured, Return value = " + Str(lRetVal), 0) 
    RegCloseKey_(hKey) 
    Error  = 0 
    ProcedureReturn Error 
  EndIf 
EndProcedure

GetValue(#HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","ProductName", "")
Result = FindString(GetValue, "7", 1)
If Result = 0
MessageRequester("Error","This is not WINDOWS 7 bye", #MB_ICONERROR)
End
Else
SetValue(#HKEY_CURRENT_USER , "Software\Microsoft\Windows\CurrentVersion\Explorer", "EnableAutoTray", "0", #REG_SZ, "")
Result = MessageRequester("Information","Going to LogOff LogOn Proceed?", #PB_MessageRequester_YesNo)
If Result = #PB_MessageRequester_Yes
RunProgram("Shutdown.exe"," -l","",#PB_Program_Hide|#PB_Program_Wait)
EndIf
EndIf
End
It in not that much
But it is the start

RASHAD
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: Windows 7 here we come

Post by SFSxOI »

RASHAD wrote:Windows 7
Set Alwayes show all icons and notifications on taskbar PROGRAMMATIC
Tested x86/x64

Code: Select all

(#HKEY_CURRENT_USER , "Software\Microsoft\Windows\CurrentVersion\Explorer", "EnableAutoTray", "0", #REG_SZ, "")
It in not that much
But it is the start

RASHAD

Hmmm...Thanks Rashad, but I think there is a small error with your code, EnableAutoTray is a DWORD, you have it as REG_SZ. The actual registry section looks like this when its exported:

Code: Select all

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"EnableAutoTray"=dword:00000000
This is on Winodws 7 RTM 32 bit. And i'm pretty sure its a DWORD cause I was doing it all thru the beta. But a REG_SZ at 0 might work too.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Post by RASHAD »

I wonder how you could manage hanging around insulting people and still know a thing @ windows
You are superman kid (MS changed that to REG_SZ not me)

For everybody
As long as you are not a member in the gang
You will be next

Go check Joestes

http://www.purebasic.fr/english/viewtop ... icongadget

and ask Fluid Byte & netmaestro about that may be you can get answer

also check and email it to your friends

http://basic.mindteq.com/index.php/comp ... basic.html
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

RASHAD wrote:I wonder how you could manage hanging around insulting people and still know a thing @ windows
You are superman kid (MS changed that to REG_SZ not me)
what the? no insult in SFSxOI's post.
and it IS a dword, MS didn't change anything....
as for the rest of your post :?:
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Post by RASHAD »

Windows 7 7600.16385 x64
check it is REG_SZ
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Re: Windows 7 here we come

Post by lexvictory »

SFSxOI wrote:This is on Winodws 7 RTM 32 bit. And i'm pretty sure its a DWORD
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

Rashad, you're either trolling, or your control over the english language is not good enough, or it's all a misunderstanding, or you are in your right but then there are better way to say things including proof.

Let's assume it's a misunderstanding, but please re-read your post and correct things. I'm not a moderator but this kind of post is bothering me.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Post by RASHAD »

Done
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Post by cas »

RASHAD wrote:I wonder how you could manage hanging around insulting people and still know a thing @ windows
You are superman kid (MS changed that to REG_SZ not me)
Ok, i know you will say again that i am attacking you (like in other thread) but it is not MS that changed it to REG_SZ, it was you when you executed your program first time so you overwrited original key with REG_SZ (or created it without overwrite if key didn't existed before). I searched on google and i can't find any connection between "EnableAutoTray" and "REG_SZ", it is definitely still DWORD like in older versions of windows (but still, small chances are that i am wrong 8) ).

And your response to SFSxOI... I was :shock: :shock: :shock:

Don't be mad at people if they respond to your thread. :lol:




EDIT:
RASHAD wrote:Windows 7 7600.16385 x64
check it is REG_SZ
Windows 7 x64 RTM:
Image
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

RASHAD wrote:and ask Fluid Byte & netmaestro about that may be you can get answer
About what?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Post by RASHAD »

@cas
No i am not mad
and i did not say i do not believe you or the others
it is REG_DWORD in xp through win 7
But in front of me it is REG_SZ believe me
I thought it is MS to decrease the size of the reg.
remember the value always either 0 or 1
I used REG_SZ in the code and it worked
I used 0 and 1 and it worked
What can I say
If I have a way to put a snapshot so I will
Remember I did not say i do not believe you
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Post by cas »

RASHAD wrote:But in front of me it is REG_SZ believe me
I belive you, as i said in previous post, your code overwritten default DWORD key :wink: , it would be stupid from Microsoft to change something that is working fine in last couple versions of their OS because they need to maintain compatibility with older programs and decreasing registry is not an option as today we have at least 200GB hdd's in modern PC's and whole registry is maybe 30-50MB on disk without any program installed.

Anyway, if you say that it is working even if key is REG_SZ type then fine. But i like to keep it right so i would change it to DWORD in your program because you never know what checks they will add in future versions of Windows, so your program may end up broken if creating wrong key type.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Post by RASHAD »

@cas my system was running beta 2462 then I upgraded it to RTM
Now you make me suspect it is because of that and to be sure
it req me to install windows 7 on a clean hd
i do not want to do that in the time being I will do it later
Using DWORD does not upset me
You or me or any other member we do not post any code and say it is 100% perfect and do not change any thing no
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Post by cas »

It is working with REG_SZ but when i got to taskbar properties and i deactivate "Always show all icons and notifications on the taskbar" then your REG_SZ key is overwritten with DWORD key.
Looks like there is no problem , it is same if you use REG_SZ or DWORD, but as i said, future versions of windows could break this and ignore REG_SZ version of "EnableAutoTray", or maybe not but to be 100% sure that it will work, change it to DWORD as it is really simple, no need to rewrite code, just change parameter.

Here is quickly edited code which creates DWORD key:

Code: Select all

Global GetHandle.l ,hKey.l ,lType.l ,lpcbData.l ,lpData.s ,lReturnCode.l ,lhRemoteRegistry.l ,lpDataDWORD.l

Procedure.l GetValue(topKey, sKeyName.s, sValueName.s, ComputerName.s)
   Shared GetValue.s
   lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry)
   GetHandle = RegOpenKeyEx_(lhRemoteRegistry, sKeyName, 0, #KEY_READ, @hKey)             
   If GetHandle = #ERROR_SUCCESS
       lpcbData = 255
       lpData = Space(255)
       GetHandle = RegQueryValueEx_(hKey, sValueName, 0, @lType, @lpData, @lpcbData)               
                   If GetHandle = 0
                       GetValue = Left(lpData, lpcbData - 1)
                   Else
                       GetValue = ""
                   EndIf
   EndIf
   RegCloseKey_(hKey)
   ProcedureReturn GetHandle
EndProcedure

   
Procedure.l SetValue(topKey.l, sKeyName.s, sValueName.s, vValue.l, lType.l, ComputerName.s)
  If ComputerName = ""
    GetHandle = RegOpenKeyEx_(topKey, sKeyName, 0, #KEY_ALL_ACCESS, @hKey)
  Else
    lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry)
    GetHandle = RegOpenKeyEx_(lhRemoteRegistry, sKeyName, 0, #KEY_ALL_ACCESS, @hKey)
  EndIf

  If GetHandle = #ERROR_SUCCESS
    lpcbData = 255
    lpData = Space(255)
        GetHandle = RegSetValueEx_(hkey, sValueName, 0, #REG_DWORD, @vValue, 4)
    RegCloseKey_(hkey)
    Error = 1
    ProcedureReturn Error
  Else
    MessageRequester("Error", "An Error occured, Return value = " + Str(lRetVal), 0)
    RegCloseKey_(hKey)
    Error  = 0
    ProcedureReturn Error
  EndIf
EndProcedure

GetValue(#HKEY_LOCAL_MACHINE,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","ProductName", "")
Result = FindString(GetValue, "7", 1)
If Result = 0
MessageRequester("Error","This is not WINDOWS 7 bye", #MB_ICONERROR)
End
Else
SetValue(#HKEY_CURRENT_USER , "Software\Microsoft\Windows\CurrentVersion\Explorer", "EnableAutoTray", 0, #REG_DWORD, "")
Result = MessageRequester("Information","Going to LogOff LogOn Proceed?", #PB_MessageRequester_YesNo)
If Result = #PB_MessageRequester_Yes
RunProgram("Shutdown.exe"," -l","",#PB_Program_Hide|#PB_Program_Wait)
EndIf
EndIf
End 
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Post by RASHAD »

@cas
Yoy ara absolutely right
I am tired even I did not read your first post carefuly
sorry boys
Post Reply