Results 1 to 5 of 5

Thread: assign Variable a path ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Dullawhere
    Posts
    100

    Question

    This is what i want to do:
    Get a registry value and asign it to a Variable, then make a
    Code:
    Shell " 'The Variable "
    in a diferent thing.

    I am guessing that the hardest part would be to get that value. If someone could give me the exact code, the regstry path is :

    HKEY_CURRENT_USER\Control Panel\Desktop\ and there is a Key called " SCRNSAVE.EXE". I want the value of that key. For all yous, that is the screen saver key for windows. Anyways, any help would be appreciated.
    I am stupid..but I AM 15 !
    *a line from a song i wrote*
    """"""""""""""""""""""""""""""""""""""""
    so i came to say life bites away
    whats done is done the past is gone
    i cant believe the sh*t I know
    i always wish it would just go
    """"""""""""""""""""""""""""""""""""""""
    "remember you Ps And Qs Boy !"

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Or check out the answer to this same question you asked a few days ago.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Dullawhere
    Posts
    100
    yes and guess what, i couldn't figure it out and i didn't get the answer i was looking for
    I am stupid..but I AM 15 !
    *a line from a song i wrote*
    """"""""""""""""""""""""""""""""""""""""
    so i came to say life bites away
    whats done is done the past is gone
    i cant believe the sh*t I know
    i always wish it would just go
    """"""""""""""""""""""""""""""""""""""""
    "remember you Ps And Qs Boy !"

  5. #5
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Well if you don't understand the answer to a question someone asks you, you should at least reply saying so and then perhaps someone can offer you more help in understanding it or getting the correct answer, but when you don't reply either one of two things are assumed.

    a. You didn't read the reply
    or
    b. The code worked and you need no further assistance

    Anyway the SCRNSAVE.exe is not on every windows computer, on my system (win95) the path to the current screensaver for windows is stored in the System.ini file.

    So if you are positive that is the path to the key then this is the code that should do exactly what you want.

    Code:
    Option Explicit
    
    Private Const REG_SZ = 1 ' Unicode nul terminated string
    Private Const REG_BINARY = 3  ' Free form binary
    Private Const HKEY_CURRENT_USER = &H80000001
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    
    Private Sub Form_Load()
    Dim lKey as Long
    Dim sScreenSaver as String
    
    RegOpenKey HKEY_CURRENT_USER, "Control Panel\desktop", lKey
    
    sScreenSaver = RegVal(lKey, "SCRNSAVE.EXE")
    
    RegCloseKey lKey
    
    Shell sScreenSaver
    
    End Sub
    
    Private Function RegVal(pKey As Long, pValName As String) As String
      Dim lValueType As Long, lBufSize As Long
      Dim strOut As String
      Dim lret As Long
        
     lret = RegQueryValueEx(pKey, pValName, 0, lValueType, ByVal 0, lBufSize)
      
     If lret = 0 Then
        
        If lValueType = REG_SZ Then
         
            strOut = String(lBufSize, Chr(0))
         
            lret = RegQueryValueEx(pKey, pValName, 0, 0, ByVal strOut, lBufSize)
         
        ElseIf lValueType = REG_BINARY Then
         Dim iOut As Integer
         
            lret = RegQueryValueEx(pKey, pValName, 0, 0, iOut, lBufSize)
            
            strOut = CStr(iOut)
            
        End If
         
        RegVal = strOut
        
     Else
     
        RegVal = ""
        
     End If
     
    End Function
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width