Announcement

Collapse
No announcement yet.

Registry: WinME/2000

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Registry: WinME/2000

    I'm using the following code under Win9*/NT and it works fine here.
    I just can't try this under WinME/2000, and I'm wondering if there
    will be a problem, do I have to use the 32bit-Reg*Ex-versions?

    Thanks and regards,
    Hanns


    Code:
    #Compile Exe
    #Register None
    #Dim All
    #Include "Win32Api.Inc"
    
      Function PbMain
    
         Dim HKEY_CLASSES_ROOT AS LONG       : HKEY_CLASSES_ROOT = &H80000000
         Dim REG_SZ            AS LONG       : REG_SZ = 1
         Dim Path              AS ASCIIZ*256 : Path="C:\PBDLL60\BiAS7"
         Dim KeyName           AS ASCIIZ*256 : KeyName = "BiAS"
         Dim KeyValue          AS ASCIIZ*256 : KeyValue = Path+"\BiAS.EXE" + " %1"  ' App-Path
         Dim KeyHandle         AS LONG
    
         RegCreateKey HKEY_CLASSES_ROOT, KeyName, KeyHandle
         If ISFALSE(KeyHandle) then EXIT FUNCTION
         RegSetValue KeyHandle, "shell\open\command", REG_SZ, KeyValue, %MAX_PATH
         RegCloseKey KeyHandle
    
         KeyName = "BiAS\shell\open\command"
         RegOpenKey HKEY_CLASSES_ROOT,KeyName,KeyHandle
         If ISFALSE(KeyHandle) then EXIT FUNCTION
         RegQueryValue HKEY_CLASSES_ROOT,KeyName,Path,%MAX_PATH
         RegCloseKey KeyHandle
    
         Path=MID$(Path,1,INSTR(-1,Path,"\")-1)
         MsgBox Path                             ' same as above?
    
         KeyName = "BiAS\shell\open\command"     ' kill the entry
         RegDeleteKey HKEY_CLASSES_ROOT, KeyName
         KeyName = "BiAS\shell\open"
         RegDeleteKey HKEY_CLASSES_ROOT, KeyName
         KeyName = "BiAS\shell"
         RegDeleteKey HKEY_CLASSES_ROOT, KeyName
         KeyName = "BiAS"
         RegDeleteKey HKEY_CLASSES_ROOT, KeyName
       
    
    End Function

    ------------------


    [This message has been edited by Hanns Ackermann (edited November 20, 2000).]

  • #2
    Best answer I can give is that NT (4 and 2000) cannot delete keys without all sub-keys being removed first.

    It looks like that's what your doing. I'm not sure but you may have to delete the values listed under the "BiAS\shell\open\command"
    key first before removing the parent keys.

    As for ME maybe it is following suit with NT to continue the merge of the OS'

    ------------------
    George W. Bleck
    Senior System Engineer
    KeySpan Corporation
    <b>George W. Bleck</b>
    <img src='http://www.blecktech.com/myemail.gif'>

    Comment


    • #3
      I use the RegCreateKeyEx function since Microsoft claims the RegCreatKey
      function is obsolete. It works fine on NT/2000/ME.

      Jeff

      ------------------

      Comment


      • #4
        George and Jeff,

        indeed, (dis)trusting MS and after having a closer look at the examples found
        in the source code forum (Dave, Don), it's an easy task to exchange the
        relevant functions. Further below the modified example using RegCreateKeyEx etc.

        Many thanks & regards,
        Hanns


        Code:
        #Compile Exe
        #Register None
        #Dim All
        #Include "Win32Api.Inc"
        
          Function PbMain
        
             Dim Path              AS ASCIIZ*256 : Path="C:\PBDLL60\BiAS7"
             Dim KeyName           AS ASCIIZ*256 : KeyName = "BiAS\shell\open\command"
             Dim KeyValue          AS ASCIIZ*256 : KeyValue = Path+"\BiAS.EXE" + " %1" ' App-Path
             Dim KeyHandle         AS LONG
             Dim KeyType           AS LONG
             Dim lDisposition      AS LONG
             
             RegCreateKeyEx %HKEY_CLASSES_ROOT, KeyName, 0, "", %REG_OPTION_NON_VOLATILE, _
                            %KEY_ALL_ACCESS, BYVAL %NULL, KeyHandle, lDisposition
             If ISFALSE(KeyHandle) then EXIT FUNCTION
             RegSetValueEx KeyHandle, "", 0, %REG_SZ, KeyValue, LEN(KeyValue)+1
             RegCloseKey KeyHandle
        
             RegOpenKeyEx %HKEY_CLASSES_ROOT, KeyName, 0, %KEY_READ, KeyHandle
             If ISFALSE(KeyHandle) then EXIT FUNCTION
             RegQueryValueEx KeyHandle, "", 0, KeyType, Path, %MAX_PATH
             RegCloseKey KeyHandle
             
             Path=MID$(Path,1,INSTR(-1,Path,"\")-1)       ' same as above?
             MsgBox Path
             
             KeyName = "BiAS\shell\open\command"
             RegDeleteKey %HKEY_CLASSES_ROOT, KeyName
             KeyName = "BiAS\shell\open"
             RegDeleteKey %HKEY_CLASSES_ROOT, KeyName
             KeyName = "BiAS\shell"
             RegDeleteKey %HKEY_CLASSES_ROOT, KeyName
             KeyName = "BiAS"
             RegDeleteKey %HKEY_CLASSES_ROOT, KeyName
        
          End Function

        ------------------


        [This message has been edited by Hanns Ackermann (edited November 21, 2000).]

        Comment


        • #5
          And also, I understand Microsoft is complaining about the size of the registry because of the "Basic" install and is now recommending going back to .INI files.

          And ya know, they are a bit easier and more stable to work with...

          I'm finding that I'm going back to them, makes things easier and doesn't risk screwing up the registry...

          Scott

          ------------------
          Scott
          mailto:[email protected][email protected]</A>
          Scott Turchin
          MCSE, MCP+I
          http://www.tngbbs.com
          ----------------------
          True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

          Comment


          • #6
            ****, just forgot the second RegCloseKey, corrected it above.

            Scott, I hope I'll get it.

            Regards again, Hanns.


            ------------------

            Comment


            • #7
              In order to have your software Microsoft "certified" I believe
              you still need to use the registry. I think the some of the problems
              they were having is that some software would store large amounts of
              binary data in the clipboard. This led to corruption. If you read the
              MSDN information, Microsoft still recommends using the clipboard. I have
              seen the article from Microsoft calling for programmers to use INI
              files again. Here's what MS says about the GetPrivateProfileString
              function ( and others in that category)


              GetPrivateProfileString
              The GetPrivateProfileString function retrieves a string from the specified section in an initialization file.

              Note This function is provided only for compatibility with 16-bit Windows-based applications. Win32-based applications should store initialization information in the registry.


              ------------------

              Comment

              Working...
              X