Results 1 to 16 of 16

Thread: Run Time Error?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Run Time Error?

    Hey guys I have a prob, one of the users of a prog I made gets this error and I have no idea what it means or how to address it

    Run-time error '-2147217396 (8004100c)':

    Automation error

    does anyone know how I can fix that?

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Run Time Error?

    What does the program do? Is the user who's experiencing problems running under Vista? Has it ever worked for that user?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Run Time Error?

    Nope, it never worked for them.

    They are using Win Xp PRO Sp2.

    Its a program that when loads, searches for hardware on people machines and then gives info about the hardware device.

  4. #4
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Run Time Error?

    You do distribute it as a Package and not just the .exe don't you ?

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Run Time Error?

    Umm, well I use inno setup and I add vb run time files with it

    It has the files the prog needs to run, the access database, the textfile

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Run Time Error?

    at what point does the error occur, are you using WMI?
    it appears this is a common error type when using WMI in vista
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Run Time Error?

    I've come upon problems with distributing an application using Access if the target machine has an 'old' version of MDAC I think 2.8 and above is what's required. Perhaps you could post the code

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Run Time Error?

    Sure here it is..


    VB Code:
    1. Private Sub Form_Load()
    2. 'mnuUpdates.Enabled = False
    3.  
    4.  
    5. Dim objSoftware As WbemScripting.SWbemServices
    6. Dim objOpsystem As WbemScripting.SWbemObjectSet
    7. Dim objThisSys As WbemScripting.SWbemObject
    8. Dim styOpSys As String
    9. Dim strComputer As String
    10. strComputer = "."
    11. Set objSoftware = GetObject("winmgmts:" _
    12.     & "{impersonationLevel=impersonate}!\\" _
    13.     & strComputer & "\root\cimv2")
    14. Set objOpsystem = objSoftware.ExecQuery _
    15.     ("Select * from Win32_OperatingSystem")
    16.  
    17. For Each objThisSys In objOpsystem
    18.     '
    19.     ' Opsystem name and location
    20.     ' eg Microsoft Windows XP Home Edition|C:\WINDOWS|\Device\Harddisk0\Partition1
    21.     '
    22.     Debug.Print objThisSys.Name
    23.     '
    24.     ' Service Pack version
    25.     ' eg Service Pack 2
    26.     '
    27.     Debug.Print objThisSys.csdversion
    28.     '
    29.     ' Base version
    30.     ' eg 5.1.2600
    31.     '
    32.     Debug.Print objThisSys.Version
    33. Next
    34.  
    35.  
    36. For Each objThisSys In GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from Win32_OperatingSystem")
    37. With objThisSys
    38. Select Case Int(Val(.Version))
    39. Case 6
    40. Text3 = "Windows Vista"
    41. Case 5
    42. Text3 = "Windows XP"
    43. Case 4
    44. Text3 = "Windows 2000"
    45. 'etc.
    46. Case 5
    47. Text3 = "Windows ME"
    48. Case 6
    49. Text3 = "Windows 95"
    50.  
    51.  
    52. Case 7
    53. Text3 = "Windows 98"
    54. End Select
    55. End With
    56. Next
    57.  
    58. 'Dim objThisSys As Object
    59. For Each objThisSys In GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from Win32_OperatingSystem")
    60. With objThisSys
    61. Text2.Text = Text2 & .Name & ", " & .csdversion & ", " & .Version & vbCrLf
    62. End With
    63. Next
    64.  
    65. 'Label23.Caption = strMsg
    66. Label3.Visible = False
    67. QuickSystemInfoFrame.Visible = False
    68. fraProperties.Visible = True
    69. Frame1.Visible = True
    70.  
    71.      Text14.Text = ("Computer name: " & Environ("computername"))
    72. Text10.Text = ("Type of Operating System: " & Text2)
    73. 'Text10.Text = ("Type of Operating System: " & Environ("OS"))
    74. 'Label23.Caption = Environ("OS")
    75. Text5.Text = ("Number of Processors: " & Environ("NUMBER_OF_PROCESSORS"))
    76. Text13.Text = ("Processor Architecture: " & Environ("PROCESSOR_ARCHITECTURE"))
    77. Label26.Caption = Environ("PROCESSOR_ARCHITECTURE")
    78. Text12.Text = ("Processor Indentifier: " & Environ("PROCESSOR_IDENTIFIER"))
    79. Text15.Text = ("Processor Level: " & Environ("PROCESSOR_LEVEL"))
    80. Text7.Text = ("Processor Revision: " & Environ("PROCESSOR_REVISION"))
    81. Text8.Text = ("Current UserName: " & Environ("USERNAME"))
    82. Text9.Text = ("Location of User Profile: " & Environ("USERPROFILE"))
    83. Text6.Text = (Environ("SystemDrive"))
    84. Text11.Text = ("System Root: " & Environ("SystemRoot"))
    85. ' Initialize the ListView
    86.     lsvProperties.ColumnHeaders.Add , , "Property"
    87.     lsvProperties.ColumnHeaders.Add , , "Value"
    88.     lsvProperties.View = lvwReport
    89.     lsvProperties.ColumnHeaders(1).Width = lsvProperties.Width / 2 - 40
    90.     lsvProperties.ColumnHeaders(2).Width = lsvProperties.Width / 2 - 40
    91.     ' Get the hardware list
    92.     cmdRefresh_Click
    93.  
    94. ''begin battery status code''
    95. lstInfo.AddItem "BatteryFullTime = " & Format$(Val(SysInfo.BatteryFullTime) * (1 / 3600), "##.0") & " Hours"
    96. lstInfo.AddItem "BatteryLifeTime = " & Format$(Val(SysInfo.BatteryLifeTime) * (1 / 3600), "##.0")
    97. lstInfo.AddItem "BatteryLifePercent = " & Format$(SysInfo.BatteryLifePercent / 100, "Percent")
    98.        
    99. Select Case SysInfo.BatteryStatus
    100. Case 1
    101.         lstInfo.AddItem "BatteryStatus = HIGH"
    102. Case 2
    103.         lstInfo.AddItem "BatteryStatus = LOW"
    104. Case 4
    105.         lstInfo.AddItem "BatteryStatus = CRITICAL"
    106. Case 128
    107.         lstInfo.AddItem "BatteryStatus = NO BATTERY"
    108. Case 255
    109.         lstInfo.AddItem "BatteryStatus = UNKNOWN"
    110. End Select
    111. '''end battery status code'''
    112.  
    113.    Dim wbemServices As Object
    114.           Dim wbemObject As Object
    115.           Dim wbemObjectSet As Object
    116.           Dim wbemCounter As Integer
    117.           Dim stemp As Long
    118.           Set wbemServices = GetObject("winmgmts:" & "\\localhost\root\wmi")
    119.           Set wbemObjectSet = wbemServices.InstancesOf("MSAcpi_ThermalZoneTemperature")
    120.         For Each wbemObject In wbemObjectSet
    121.  
    122.              stemp = (wbemObject.CurrentTemperature - 2732) / 10
    123.  
    124.           Next
    125.  
    126. Label14 = stemp
    127. If Label26.Caption = "x86" Then
    128. Label28.Caption = "32-bit"
    129.  
    130. End If
    131.  Dim iFileNo As Integer
    132.   Dim sFileText As String
    133.  
    134.  
    135. End Sub
    136.  
    137.  
    138.  
    139. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    140.  
    141. ShellExecute Me.hwnd, "open", "http://www.geocities.com/nitrogenocide2003/MHXBuy2.html", vbNullString, vbNullString, ByVal 1&
    142. Unload fComputerInfo
    143.        MP3Stop
    144.        UnloadAllForms Me
    145. End Sub
    146.  
    147.  
    148.  
    149. Private Sub Frame7_DragDrop(Source As Control, X As Single, y As Single)
    150.  
    151. End Sub
    152.  
    153. Private Sub Label21_Click()
    154.   ShellExecute Me.hwnd, "open", "mailto:[email protected]", vbNullString, vbNullString, vbNormalFocus
    155. End Sub
    156.  
    157. Private Sub Label29_Click()
    158. ShellExecute Me.hwnd, "open", "http://www.geocities.com/nitrogenocide2003/MHXBuy2.html", vbNullString, vbNullString, ByVal 1&
    159. End Sub
    160.  
    161.  
    162.  
    163.  
    164.  
    165.  
    166. Private Sub Label6_Click()
    167. MsgBox "MHX Driver Searcher End User Licence Agreement: Revised March 19/2008. You (the user) are hereby allowed to use the free version on as many computers as you want for any reason. But by installing this software you agree not to reverse enginneer any part of this prog. The author of this program does not take ANY reponsibility for ANY usage of this program. Note: it may be wise to uninstall older versions or free versions before installing newer or the professional edition. The professional version can be install as many times as you wish on up to 3 computers."
    168. End Sub
    169.  
    170. Private Sub mnuAbout_Click()
    171. About.Show
    172. End Sub
    173.  
    174. Private Sub mnuBuy_Click()
    175. ShellExecute Me.hwnd, "open", "http://www.geocities.com/nitrogenocide2003/MHXBuy2.html", vbNullString, vbNullString, ByVal 1&
    176. End Sub
    177.  
    178. Private Sub mnuExit_Click()
    179.  
    180.  
    181. MP3Stop
    182. Call UnloadAllForms(Me)
    183.  
    184. Unload Me
    185.  
    186. End Sub
    187.  
    188. Private Sub mnuFREE_Click()
    189. ShellExecute Me.hwnd, "open", "http://microhardxce.vze.com", vbNullString, vbNullString, ByVal 1&
    190. End Sub
    191.  
    192. Private Sub mnuSupport_Click()
    193. ShellExecute Me.hwnd, "open", "http://z15.invisionfree.com/MicroHARDxce_Forums/index.php?", vbNullString, vbNullString, ByVal 1&
    194. End Sub
    195.  
    196. Private Sub RichTextBox1_Change()
    197.  
    198. End Sub
    199.  
    200.  
    201.  
    202. Private Sub TabStrip1_Click()
    203.  
    204. With TabStrip1
    205.         Select Case .SelectedItem.Caption
    206.        
    207.        
    208.             Case "Hardware Information"
    209.        fraProperties.Visible = True
    210.        Frame1.Visible = True
    211.        QuickSystemInfoFrame.Visible = False
    212.        trvComputer.Visible = True
    213.      
    214.        Frame3.Visible = True
    215.    
    216.        
    217.      
    218.         Case "System Information"
    219.         fraProperties.Visible = False
    220.        Frame1.Visible = False
    221.        QuickSystemInfoFrame.Visible = True
    222.    
    223.           Frame3.Visible = False
    224.           trvComputer.Visible = False
    225.      
    226.        
    227.      
    228.    
    229.                
    230.                
    231.                 Case "Live Help"
    232.                 chatclient.Show
    233.              
    234.         End Select
    235.     End With
    236.  
    237. End Sub
    238.  
    239. Private Sub Timer1_Timer()
    240. If IsPlaying = False And Command1.Enabled = False And Command2.Caption = "Pause" Then MP3Play hwnd, nFileName
    241. End Sub
    242.  
    243. Private Sub trvComputer_Click()
    244. Dim vFullPath As Variant
    245. Dim vItems As Variant
    246. Dim vTemp As Variant
    247.  
    248.     ' Put the path parts of selected item into a variant array
    249.     vFullPath = Split(trvComputer.SelectedItem.FullPath, "\")
    250.     ' Check whether the user choose a device name
    251.     If UBound(vFullPath) = 2 Then
    252.         ' Update the TextBox with the chosen device name
    253.         txtDevice.Text = vFullPath(2)
    254.         Label19.Caption = vFullPath(2)
    255.         On Error Resume Next
    256.         ' Clear the ListView
    257.         lsvProperties.ListItems.Clear
    258.         ' Populate the ListView with the device's properties
    259.         For Each vTemp In GetProperties(vFullPath)
    260.             On Error Resume Next
    261.             vItems = Split(vTemp, "^")
    262.             lsvProperties.ListItems.Add(, , CStr(vItems(0))).SubItems(1) = vItems(1)
    263.         Next vTemp
    264.         ' Resize the columns width (in the ListView)
    265.         Call AutosizeColumns(lsvProperties)
    266.     End If
    267. End Sub
    268.  
    269. Private Function GetProperties(vPath As Variant) As Variant
    270. ' This function returns all the properties of a specific device
    271. Dim DeviceSet As SWbemObjectSet
    272. Dim Device As SWbemObject
    273. Dim iCount As Integer
    274. Dim vTemp As Variant
    275. Dim stemp As String
    276.  
    277.     On Error Resume Next
    278.     ' Set theSWbemObjectSet object
    279.     Set DeviceSet = GetObject("winmgmts:").InstancesOf("Win32_" & vPath(1))
    280.     For Each Device In DeviceSet
    281.         ' Check if the current device in the chosen device
    282.         If Device.Caption = vPath(2) Then
    283.             ' Get all the properties of the chosen device
    284.             For Each vTemp In Device.Properties_
    285.                 On Error Resume Next
    286.                 If vTemp <> "" And vTemp <> vbNull Then
    287.                     ' Add the property name and its value to the temporary string
    288.                     stemp = stemp & vTemp.Name & "^" & vTemp & "|"
    289.                 End If
    290.             Next
    291.             ' Remove the '|' character at the end of the string
    292.             If Right(stemp, 1) = "|" Then
    293.                 stemp = Left(stemp, Len(stemp) - 1)
    294.             End If
    295.         End If
    296.     Next Device
    297.     ' Return an array containing the device properties
    298.     GetProperties = Split(stemp, "|")
    299. End Function
    300.  
    301.  
    302. [B][/B]

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Run Time Error?

    And

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    4. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    5. ByVal hwnd As Long, _
    6. ByVal lpOperation As String, _
    7. ByVal lpFile As String, _
    8. ByVal lpParameters As String, _
    9. ByVal lpDirectory As String, _
    10. ByVal nShowCmd As Long) As Long
    11.  
    12. Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
    13. Private Type MEMORYSTATUS
    14.         dwLength As Long
    15.         dwMemoryLoad As Long
    16.         dwTotalPhys As Long
    17.         dwAvailPhys As Long
    18.         dwTotalPageFile As Long
    19.         dwAvailPageFile As Long
    20.         dwTotalVirtual As Long
    21.         dwAvailVirtual As Long
    22.    
    23.         End Type
    24.         Private blnQuit As Boolean
    25.         Private Declare Function GetTickCount& Lib "kernel32" ()
    26.  Private Const SND_APPLICATION = &H80         '  look for application specific association
    27.  
    28.       Private Const SND_ALIAS = &H10000     '  name is a WIN.INI [sounds] entry
    29.  
    30.       Private Const SND_ALIAS_ID = &H110000    '  name is a WIN.INI [sounds] entry identifier
    31.  
    32.       Private Const SND_ASYNC = &H1         '  play asynchronously
    33.  
    34.       Private Const SND_FILENAME = &H20000     '  name is a file name
    35.  
    36.       Private Const SND_LOOP = &H8         '  loop the sound until next sndPlaySound
    37.  
    38.       Private Const SND_MEMORY = &H4         '  lpszSoundName points to a memory file
    39.  
    40.       Private Const SND_NODEFAULT = &H2         '  silence not default, if sound not found
    41.  
    42.       Private Const SND_NOSTOP = &H10        '  don't stop any currently playing sound
    43.  
    44.       Private Const SND_NOWAIT = &H2000      '  don't wait if the driver is busy
    45.  
    46.       Private Const SND_PURGE = &H40               '  purge non-static events for task
    47.  
    48.       Private Const SND_RESOURCE = &H40004     '  name is a resource name or atom
    49.  
    50.       Private Const SND_SYNC = &H0         '  play synchronously (default)
    51.  
    52.    
    53.       Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
    54.    
    55.       Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    56.    
    57.       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
    58.    
    59.       Const REG_SZ = 1
    60.    
    61.      Const HKEY_LOCAL_MACHINE = &H80000001
    62.    
    63.       Const REGKEY = "Software\Microsoft\Windows\CurrentVersion\Run"
    64.    
    65.       Const KEY_WRITE = &H20006
    66.       ''' Code for chat user names.
    67.      ' Option Explicit
    68.  
    69. Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
    70. Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
    71. Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
    72. Private mmOpen As String, sec As Integer, mins As Integer
    73. Dim nFileName As String
    74. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    75.                 (ByVal hwnd As Long, ByVal wMsg As Long, _
    76.                  ByVal wParam As Long, lParam As Any) As Long
    77.                  
    78.      
    79.  
    80.  
    81.         Public Function IsPlaying() As Boolean
    82. Static s As String * 30
    83. mciSendString "status MP3Play mode", s, Len(s), 0
    84. IsPlaying = (Mid$(s, 1, 7) = "playing")
    85. End Function
    86.  
    87.  
    88.            
    89.   Public Function MP3Play(wndHandle As Long, sFileName As String)
    90.   Dim cmdToDo As String * 255
    91.   Dim dwReturn As Long
    92.   Dim Ret As String * 128
    93.   Dim tmp As String * 255
    94.   Dim lenShort As Long
    95.   Dim ShortPathAndFie As String, glo_HWND As Long
    96.     If Dir(sFileName) = "" Then
    97.          mmOpen = "Error with input file"
    98.          Exit Function
    99.     End If
    100.   lenShort = GetShortPathName(sFileName, tmp, 255)
    101.   ShortPathAndFie = Left$(tmp, lenShort)
    102.   glo_HWND = wndHandle
    103.   cmdToDo = "open " & ShortPathAndFie & " type MPEGVideo Alias MP3Play"
    104.   dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&)
    105.   If dwReturn <> 0 Then  'not success
    106.      mciGetErrorString dwReturn, Ret, 128
    107.      mmOpen = Ret
    108.      MsgBox Ret, vbCritical
    109.      Exit Function
    110.   End If
    111.   mmOpen = "Success"
    112.   mciSendString "play MP3Play", 0, 0, 0
    113. End Function
    114.  
    115. Public Function MP3Pause()
    116.   mciSendString "pause MP3Play", 0, 0, 0
    117. End Function
    118.  
    119. Public Function MP3UnPause()
    120.   mciSendString "play MP3Play", 0, 0, 0
    121. End Function
    122.  
    123. Public Function MP3Stop() As String
    124.   mciSendString "stop MP3Play", 0, 0, 0
    125.   mciSendString "close MP3Play", 0, 0, 0
    126. End Function
    127.  
    128. Function StripNulls(OriginalStr As String) As String
    129.     If (InStr(OriginalStr, Chr(0)) > 0) Then
    130.         OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
    131.     End If
    132.     StripNulls = OriginalStr
    133. End Function
    134.  
    135. Private Function GetDevice(DeviceName As String) As Variant
    136. ' In this function we will get the devices referring to the given class name
    137. Dim DeviceSet As SWbemObjectSet
    138. Dim Device As SWbemObject
    139. Dim iCount As Integer
    140. Dim stemp As String
    141.  
    142.     On Error Resume Next
    143.     ' Set the SWbemObjectSet object
    144.     Set DeviceSet = GetObject("winmgmts:").InstancesOf(DeviceName)
    145.    
    146.     ' Get the devices captions
    147.     For Each Device In DeviceSet
    148.         stemp = stemp & Device.Caption & "|"
    149.     Next Device
    150.     ' Remove the '|' character at the end of the string
    151.     If Right(stemp, 1) = "|" Then stemp = Left(stemp, Len(stemp) - 1)
    152.     ' Return an array (variant) with the devices captions
    153.     GetDevice = Split(stemp, "|")
    154. End Function
    155.  
    156.    
    157. Private Sub UnloadAllForms(AForm As Form)
    158.  
    159.     'This code shuts down all forms and prevents multiple instances
    160.     ' if any other programs are made, make sure they include this code.
    161.     Dim frm As Form
    162.    
    163.     For Each frm In Forms
    164.         If frm.Name <> AForm.Name Then
    165.             Unload frm
    166.             Set frm = Nothing
    167.         End If
    168.     Next
    169.  
    170.  
    171. End Sub

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Run Time Error?

    AND

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    4. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    5. ByVal hwnd As Long, _
    6. ByVal lpOperation As String, _
    7. ByVal lpFile As String, _
    8. ByVal lpParameters As String, _
    9. ByVal lpDirectory As String, _
    10. ByVal nShowCmd As Long) As Long
    11.  
    12. Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
    13. Private Type MEMORYSTATUS
    14.         dwLength As Long
    15.         dwMemoryLoad As Long
    16.         dwTotalPhys As Long
    17.         dwAvailPhys As Long
    18.         dwTotalPageFile As Long
    19.         dwAvailPageFile As Long
    20.         dwTotalVirtual As Long
    21.         dwAvailVirtual As Long
    22.    
    23.         End Type
    24.         Private blnQuit As Boolean
    25.         Private Declare Function GetTickCount& Lib "kernel32" ()
    26.  Private Const SND_APPLICATION = &H80         '  look for application specific association
    27.  
    28.       Private Const SND_ALIAS = &H10000     '  name is a WIN.INI [sounds] entry
    29.  
    30.       Private Const SND_ALIAS_ID = &H110000    '  name is a WIN.INI [sounds] entry identifier
    31.  
    32.       Private Const SND_ASYNC = &H1         '  play asynchronously
    33.  
    34.       Private Const SND_FILENAME = &H20000     '  name is a file name
    35.  
    36.       Private Const SND_LOOP = &H8         '  loop the sound until next sndPlaySound
    37.  
    38.       Private Const SND_MEMORY = &H4         '  lpszSoundName points to a memory file
    39.  
    40.       Private Const SND_NODEFAULT = &H2         '  silence not default, if sound not found
    41.  
    42.       Private Const SND_NOSTOP = &H10        '  don't stop any currently playing sound
    43.  
    44.       Private Const SND_NOWAIT = &H2000      '  don't wait if the driver is busy
    45.  
    46.       Private Const SND_PURGE = &H40               '  purge non-static events for task
    47.  
    48.       Private Const SND_RESOURCE = &H40004     '  name is a resource name or atom
    49.  
    50.       Private Const SND_SYNC = &H0         '  play synchronously (default)
    51.  
    52.    
    53.       Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
    54.    
    55.       Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    56.    
    57.       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
    58.    
    59.       Const REG_SZ = 1
    60.    
    61.      Const HKEY_LOCAL_MACHINE = &H80000001
    62.    
    63.       Const REGKEY = "Software\Microsoft\Windows\CurrentVersion\Run"
    64.    
    65.       Const KEY_WRITE = &H20006
    66.       ''' Code for chat user names.
    67.      ' Option Explicit
    68.  
    69. Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
    70. Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
    71. Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
    72. Private mmOpen As String, sec As Integer, mins As Integer
    73. Dim nFileName As String
    74. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    75.                 (ByVal hwnd As Long, ByVal wMsg As Long, _
    76.                  ByVal wParam As Long, lParam As Any) As Long
    77.                  
    78.      
    79.  
    80.  
    81.         Public Function IsPlaying() As Boolean
    82. Static s As String * 30
    83. mciSendString "status MP3Play mode", s, Len(s), 0
    84. IsPlaying = (Mid$(s, 1, 7) = "playing")
    85. End Function
    86.  
    87.  
    88.            
    89.   Public Function MP3Play(wndHandle As Long, sFileName As String)
    90.   Dim cmdToDo As String * 255
    91.   Dim dwReturn As Long
    92.   Dim Ret As String * 128
    93.   Dim tmp As String * 255
    94.   Dim lenShort As Long
    95.   Dim ShortPathAndFie As String, glo_HWND As Long
    96.     If Dir(sFileName) = "" Then
    97.          mmOpen = "Error with input file"
    98.          Exit Function
    99.     End If
    100.   lenShort = GetShortPathName(sFileName, tmp, 255)
    101.   ShortPathAndFie = Left$(tmp, lenShort)
    102.   glo_HWND = wndHandle
    103.   cmdToDo = "open " & ShortPathAndFie & " type MPEGVideo Alias MP3Play"
    104.   dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&)
    105.   If dwReturn <> 0 Then  'not success
    106.      mciGetErrorString dwReturn, Ret, 128
    107.      mmOpen = Ret
    108.      MsgBox Ret, vbCritical
    109.      Exit Function
    110.   End If
    111.   mmOpen = "Success"
    112.   mciSendString "play MP3Play", 0, 0, 0
    113. End Function
    114.  
    115. Public Function MP3Pause()
    116.   mciSendString "pause MP3Play", 0, 0, 0
    117. End Function
    118.  
    119. Public Function MP3UnPause()
    120.   mciSendString "play MP3Play", 0, 0, 0
    121. End Function
    122.  
    123. Public Function MP3Stop() As String
    124.   mciSendString "stop MP3Play", 0, 0, 0
    125.   mciSendString "close MP3Play", 0, 0, 0
    126. End Function
    127.  
    128. Function StripNulls(OriginalStr As String) As String
    129.     If (InStr(OriginalStr, Chr(0)) > 0) Then
    130.         OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
    131.     End If
    132.     StripNulls = OriginalStr
    133. End Function
    134.  
    135. Private Function GetDevice(DeviceName As String) As Variant
    136. ' In this function we will get the devices referring to the given class name
    137. Dim DeviceSet As SWbemObjectSet
    138. Dim Device As SWbemObject
    139. Dim iCount As Integer
    140. Dim stemp As String
    141.  
    142.     On Error Resume Next
    143.     ' Set the SWbemObjectSet object
    144.     Set DeviceSet = GetObject("winmgmts:").InstancesOf(DeviceName)
    145.    
    146.     ' Get the devices captions
    147.     For Each Device In DeviceSet
    148.         stemp = stemp & Device.Caption & "|"
    149.     Next Device
    150.     ' Remove the '|' character at the end of the string
    151.     If Right(stemp, 1) = "|" Then stemp = Left(stemp, Len(stemp) - 1)
    152.     ' Return an array (variant) with the devices captions
    153.     GetDevice = Split(stemp, "|")
    154. End Function
    155.  
    156.    
    157. Private Sub UnloadAllForms(AForm As Form)
    158.  
    159.     'This code shuts down all forms and prevents multiple instances
    160.     ' if any other programs are made, make sure they include this code.
    161.     Dim frm As Form
    162.    
    163.     For Each frm In Forms
    164.         If frm.Name <> AForm.Name Then
    165.             Unload frm
    166.             Set frm = Nothing
    167.         End If
    168.     Next
    169.  
    170.  
    171. End Sub

  11. #11
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Run Time Error?

    as you havenot specified where the error is happening, hard to make any further comment, but it would appear it is a WMI issue
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Run Time Error?

    I don't know where the error could happen as it works fine on my computer.

    What is this WMI?

  13. #13
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Run Time Error?

    What is this WMI?
    windows management
    Set objSoftware = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
    you will need to use error handling to create a logfile or similar method of debugging your application, so that you know exactly which line of code is creating the error

    if you want anyone here to test your code, zip your project and attach it to a post, too hard to want to create a project with all the controls and references that may be required to make it run, from the code posted above
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  14. #14
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Run Time Error?

    Let's see that script to make sure you haven't forgotten something...

  15. #15
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Run Time Error?

    Let's see that script to make sure you haven't forgotten something...
    i believe all the code for that is in post #8
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  16. #16
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Run Time Error?

    Quote Originally Posted by westconn1
    i believe all the code for that is in post #8
    Hmmmm.... That looks like VB code not a Inno Setup Script but I could be wrong... What do I know...

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