Results 1 to 12 of 12

Thread: Help PLEASE!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    3

    Question Help PLEASE!!!

    Ok I wanna make a .exe where there is a pop-up to a website when you open the program and it registers the site into the registry, how can i do this??
    This is what i have been told to put in
    Private Sub Form_Load()
    Shell "C:\Program Files\Internet Explorer\iexplorer.exe http://yourwebsite.here"
    End Sub

    I keep getting an error when i try to use it, can someone help me with this and tell me how to do the registry thing?
    Last edited by Muteki; Mar 22nd, 2004 at 07:15 AM.

  2. #2
    Hyperactive Member ravi15481's Avatar
    Join Date
    Aug 2002
    Location
    INDIA
    Posts
    421
    use this instead

    VB Code:
    1. Private Sub Form_Load()
    2. Shell "C:\Program Files\Internet Explorer\iexplore.exe [url]http://www.yahoo.com[/url]"
    3. End Sub

    the difference is in the exe name. u have misspelled it, it is iexplore not iexplorer.
    A good friend...

  3. #3
    Hyperactive Member ravi15481's Avatar
    Join Date
    Aug 2002
    Location
    INDIA
    Posts
    421
    use the attached module to access the registry.....

    ALL THE BEST!

    Attached Files Attached Files
    A good friend...

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    3
    Hey thanks man, i don't want to ask for too much, but is there anyway you could post the registry stuff in vb code? when i dl zip files my vb will open, but it won't do anything......I would appreciate it a ton, thanx

  5. #5
    Hyperactive Member ravi15481's Avatar
    Join Date
    Aug 2002
    Location
    INDIA
    Posts
    421
    It is just a module defined with all the registry related functions that interact with win API.

    you will have to add this module to ur project and call the procedures defined inthat module. just check the functions written in the module u will know the purpose.

    still if u r unable to use it then i will send u a sample project that will use that module.
    A good friend...

  6. #6
    Hyperactive Member ravi15481's Avatar
    Join Date
    Aug 2002
    Location
    INDIA
    Posts
    421
    download the attachemnt

    unzip and open the Registry.bas file

    Execute it.

    This will

    Creates a New registry Key
    Set registry Key's Value
    get the regsitry key's value and displays
    then atlast deletes it
    Attached Files Attached Files
    A good friend...

  7. #7
    Hyperactive Member ravi15481's Avatar
    Join Date
    Aug 2002
    Location
    INDIA
    Posts
    421
    Else, copy paste the following code in a form

    VB Code:
    1. Option Explicit
    2.  
    3. Const REG_SZ As Long = 1
    4. Const REG_DWORD As Long = 4
    5.  
    6. Const HKEY_CLASSES_ROOT = &H80000000
    7. Const HKEY_CURRENT_USER = &H80000001
    8. Const HKEY_LOCAL_MACHINE = &H80000002
    9. Const HKEY_USERS = &H80000003
    10.  
    11. Const ERROR_NONE = 0
    12. Const ERROR_BADDB = 1
    13. Const ERROR_BADKEY = 2
    14. Const ERROR_CANTOPEN = 3
    15. Const ERROR_CANTREAD = 4
    16. Const ERROR_CANTWRITE = 5
    17. Const ERROR_OUTOFMEMORY = 6
    18. Const ERROR_INVALID_PARAMETER = 7
    19. Const ERROR_ACCESS_DENIED = 8
    20. Const ERROR_INVALID_PARAMETERS = 87
    21. Const ERROR_NO_MORE_ITEMS = 259
    22.  
    23. Const KEY_ALL_ACCESS = &H3F
    24.  
    25. Const REG_OPTION_NON_VOLATILE = 0
    26.  
    27. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
    28. Private Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
    29. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
    30. Private Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
    31. Private Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Long, lpcbData As Long) As Long
    32. Private Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Long, lpcbData As Long) As Long
    33. Private Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
    34. Private Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long
    35. Private Declare Function RegDeleteKey& Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String)
    36. Private Declare Function RegDeleteValue& Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String)
    37.  
    38. Public Function DeleteKey(lPredefinedKey As Long, sKeyName As String)
    39. ' Description:
    40. '   This Function will Delete a key
    41. ' Syntax:
    42. '   DeleteKey Location, KeyName
    43. '   Location must equal HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE, HKEY_USERS
    44. '   KeyName is name of the key you wish to delete, it may include subkeys (example "Key1\SubKey1")
    45.  
    46.     Dim lRetVal As Long         'result of the SetValueEx function
    47.     Dim hKey As Long         'handle of open key
    48.     'open the specified key
    49.     'lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
    50.     lRetVal = RegDeleteKey(lPredefinedKey, sKeyName)
    51.     'RegCloseKey (hKey)
    52. End Function
    53.  
    54. Public Function DeleteValue(lPredefinedKey As Long, sKeyName As String, sValueName As String)
    55. ' Description:
    56. '   This Function will delete a value
    57. ' Syntax:
    58. '   DeleteValue Location, KeyName, ValueName
    59. '   Location must equal HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE, HKEY_USERS
    60. '   KeyName is the name of the key that the value you wish to delete is in
    61. '   , it may include subkeys (example "Key1\SubKey1")
    62. '   ValueName is the name of value you wish to delete
    63.  
    64.        Dim lRetVal As Long         'result of the SetValueEx function
    65.        Dim hKey As Long         'handle of open key
    66.  
    67.        'open the specified key
    68.  
    69.        lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
    70.        lRetVal = RegDeleteValue(hKey, sValueName)
    71.        RegCloseKey (hKey)
    72. End Function
    73.  
    74. Public Function SetValueEx(ByVal hKey As Long, sValueName As String, lType As Long, vValue As Variant) As Long
    75.     Dim lValue As Long
    76.     Dim sValue As String
    77.  
    78.     Select Case lType
    79.         Case REG_SZ
    80.             sValue = vValue
    81.             SetValueEx = RegSetValueExString(hKey, sValueName, 0&, lType, sValue, Len(sValue))
    82.         Case REG_DWORD
    83.             lValue = vValue
    84.             SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, lType, lValue, 4)
    85.         End Select
    86. End Function
    87.  
    88. Function QueryValueEx(ByVal lhKey As Long, ByVal szValueName As String, vValue As Variant) As Long
    89.     Dim cch As Long
    90.     Dim lrc As Long
    91.     Dim lType As Long
    92.     Dim lValue As Long
    93.     Dim sValue As String
    94.  
    95.     On Error GoTo QueryValueExError
    96.  
    97.     ' Determine the size and type of data to be read
    98.  
    99.     lrc = RegQueryValueExNULL(lhKey, szValueName, 0&, lType, 0&, cch)
    100.     If lrc <> ERROR_NONE Then Error 5
    101.  
    102.     Select Case lType
    103.         ' For strings
    104.         Case REG_SZ:
    105.             sValue = String(cch, 0)
    106.             lrc = RegQueryValueExString(lhKey, szValueName, 0&, lType, sValue, cch)
    107.             If lrc = ERROR_NONE Then
    108.                 vValue = Left$(sValue, cch)
    109.             Else
    110.                 vValue = Empty
    111.             End If
    112.  
    113.         ' For DWORDS
    114.         Case REG_DWORD:
    115.             lrc = RegQueryValueExLong(lhKey, szValueName, 0&, lType, lValue, cch)
    116.             If lrc = ERROR_NONE Then vValue = lValue
    117.         Case Else
    118.             'all other data types not supported
    119.             lrc = -1
    120.     End Select
    121. QueryValueExExit:
    122.     QueryValueEx = lrc
    123.     Exit Function
    124. QueryValueExError:
    125.     Resume QueryValueExExit
    126. End Function
    127.  
    128. Public Function CreateNewKey(lPredefinedKey As Long, sNewKeyName As String)
    129. ' Description:
    130. '   This Function will create a new key
    131. ' Syntax:
    132. '   QueryValue Location, KeyName
    133. '   Location must equal HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE, HKEY_USERS
    134. '   KeyName is name of the key you wish to create, it may include subkeys (example "Key1\SubKey1")
    135.     Dim hNewKey As Long         'handle to the new key
    136.     Dim lRetVal As Long         'result of the RegCreateKeyEx function
    137.    
    138.     lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
    139.     RegCloseKey (hNewKey)
    140. End Function
    141.  
    142. Public Function SetKeyValue(lPredefinedKey As Long, sKeyName As String, sValueName As String, vValueSetting As Variant, lValueType As Long)
    143. ' Description:
    144. '   This Function will set the data field of a value
    145. ' Syntax:
    146. '   QueryValue Location, KeyName, ValueName, ValueSetting, ValueType
    147. '   Location must equal HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE, HKEY_USERS
    148. '   KeyName is the key that the value is under (example: "Key1\SubKey1")
    149. '   ValueName is the name of the value you want create, or set the value of (example: "ValueTest")
    150. '   ValueSetting is what you want the value to equal
    151. '   ValueType must equal either REG_SZ (a string) Or REG_DWORD (an integer)
    152.        Dim lRetVal As Long         'result of the SetValueEx function
    153.        Dim hKey As Long         'handle of open key
    154.        'open the specified key
    155.        lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
    156.        lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)
    157.        RegCloseKey (hKey)
    158. End Function
    159.  
    160. Public Function QueryValue(lPredefinedKey As Long, sKeyName As String, sValueName As String)
    161. ' Description:
    162. '   This Function will return the data field of a value
    163. '
    164. ' Syntax:
    165. '   Variable = QueryValue(Location, KeyName, ValueName)
    166. '
    167. '   Location must equal HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_lOCAL_MACHINE
    168. '   , HKEY_USERS
    169. '
    170. '   KeyName is the key that the value is under (example: "Software\Microsoft\Windows\CurrentVersion\Explorer")
    171. '
    172. '   ValueName is the name of the value you want to access (example: "link")
    173.  
    174.        Dim lRetVal As Long         'result of the API functions
    175.        Dim hKey As Long         'handle of opened key
    176.        Dim vValue As Variant      'setting of queried value
    177.  
    178.        lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
    179.        lRetVal = QueryValueEx(hKey, sValueName, vValue)
    180.        'MsgBox vValue
    181.        QueryValue = vValue
    182.        RegCloseKey (hKey)
    183. End Function
    184.  
    185. Private Sub Form_Load()
    186.     'Examples of each function:
    187.     CreateNewKey HKEY_CURRENT_USER, "TestKey\SubKey1\SubKey2"
    188.     SetKeyValue HKEY_CURRENT_USER, "TestKey\SubKey1", "Test", "Testing, Testing", REG_SZ
    189.     MsgBox QueryValue(HKEY_CURRENT_USER, "TestKey\SubKey1", "Test")
    190.     DeleteKey HKEY_CURRENT_USER, "TestKey\SubKey1\SubKey2"
    191.     DeleteValue HKEY_CURRENT_USER, "TestKey\SubKey1", "Test"
    192. End Sub

    A good friend...

  8. #8

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    3

    Talking

    thanks a ton man, you were a big help....you have any idea why vb doesn't do anything when i try to execute a prog?? sorry, i'm still a noob at this

  9. #9
    New Member
    Join Date
    Mar 2004
    Posts
    15
    Not my place to say because im new to VB but are you trying to execute a .exe file in VB? Won't work lol also make sure you extract your zip files (even when using XP) because VB doesnt like that either.

  10. #10
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    Use Shell to execute a .exe file from within VB

  11. #11
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465
    It would appear that there are a lot of things VB doesn't like...

  12. #12
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    It really isnt a VB issue, many items wont run from a Temp .zip location. It's always best to extract .zip files to a folder before trying to use them.

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