首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

请教高手这个有关问题怎么解决

2012-03-02 
请问高手这个问题如何解决?Private Declare Function RegQueryValue Lib advapi32.dll Alias RegQuery

请问高手这个问题如何解决?



Private Declare Function RegQueryValue Lib "advapi32.dll " Alias "RegQueryValueA " (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue 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 ret As Long, lenS As Long, s As String, retkey As Long, hKey As Long

Private Sub Label3_Click() '将数据导出到excell中
'--------------------------------------判斷是否已安裝 EXCEL 並取得安裝目錄--------------------------------

  retkey = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\microsoft\windows\currentversion\app paths\excel.exe ", hKey)
  If retkey = 0 Then
  ret = RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\microsoft\windows\currentversion\app paths\excel.exe ", s, lenS)
  If ret = 0 Then
  s = String(lenS, Chr(0))
  ret = RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\microsoft\windows\currentversion\app paths\excel.exe ", s, lenS)
  If ret = 0 Then
  s = Left(s, InStr(s, Chr(0)) - 1)
  Else
  MsgBox "Microsoft Excel 沒有安裝,請先安裝 Microsoft Excel 后再試! ", vbOKOnly + vbInformation
  Exit Sub
  End If
  End If
上面程序实验时报图的提示,请问高人如何解决????急-------------------谢谢

[解决办法]
复制以下程序去测试:

VB code
Private Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As LongPrivate Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, phkResult As Long) As LongPrivate ret As Long, lenS As Long, s As String, retkey As Long, hkey As LongConst HKEY_LOCAL_MACHINE As Long = &H80000002Private Sub Label3_Click() '将数据导出到excell中'--------------------------------------判斷是否已安裝 EXCEL 並取得安裝目錄-------------------------------- retkey = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\microsoft\windows\currentversion\app paths\excel.exe", hkey) If retkey = 0 Then  ret = RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\microsoft\windows\currentversion\app paths\excel.exe", s, lenS)  If ret = 0 Then   s = String(lenS, Chr(0))   ret = RegQueryValue(HKEY_LOCAL_MACHINE, "SOFTWARE\microsoft\windows\currentversion\app paths\excel.exe", s, lenS)   If ret = 0 Then    s = Left(s, InStr(s, Chr(0)) - 1)    MsgBox s   Else    MsgBox "Microsoft Excel 沒有安裝,請先安裝 Microsoft Excel 后再試! ", vbOKOnly + vbInformation    Exit Sub   End If  End If End IfEnd Sub 

热点排行