如何用程序强制系统显示文件后缀名?

sheky 2002-06-17 05:48:35
系统可以在资源管理器中设置"隐藏文件后缀名",现在我需要在我的程序每次启动的时候,强制将该设置取消.有没有高人有办法的阿?

一定给分
...全文
2146 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sheky 2002-06-18
  • 打赏
  • 举报
回复
这个隐藏文件后缀名的问题,98下没有问题,但在2000下,这样动作了以后立刻还没有效果,需要进资源管理器的设置面板以后,确定或取消后,才有效果.问题仍然没有解决!:)
qhzxcz 2002-06-17
  • 打赏
  • 举报
回复
'以下是为了操作注册表(放在模块中)

Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANCE_DATA = &H80000004
Public Const ERROR_SUCCESS = 0&

' Registry API prototypes

Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKEY As Long) As Long
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String) As Long
Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal HKEY As Long, ByVal lpValueName As String) As Long
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String, phkResult As Long) As Long
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
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
Public Const REG_SZ = 1 ' Unicode nul terminated string
Public Const REG_DWORD = 4 ' 32-bit number
Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Public Sub savekey(HKEY As Long, strPath As String)
Dim keyhand&
r = RegCreateKey(HKEY, strPath, keyhand&)
r = RegCloseKey(keyhand&)
End Sub

Public Function getstring(HKEY As Long, ByVal strPath As String, ByVal strValue As String)

Dim keyhand As Long
Dim datatype As Long
Dim lResult As Long
Dim strBuf As String
Dim lDataBufSize As Long
Dim intZeroPos As Integer
r = RegOpenKey(HKEY, strPath, keyhand)
lResult = RegQueryValueEx(keyhand, strValue, 0&, lValueType, ByVal 0&, lDataBufSize)
If lValueType = REG_SZ Then
strBuf = String(lDataBufSize, " ")
lResult = RegQueryValueEx(keyhand, strValue, 0&, 0&, ByVal strBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
intZeroPos = InStr(strBuf, Chr$(0))
If intZeroPos > 0 Then
getstring = Left$(strBuf, intZeroPos - 1)
Else
getstring = strBuf
End If
End If
End If
End Function


Public Sub savestring(HKEY As Long, ByVal strPath As String, ByVal strValue As String, ByVal strdata As String)
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(HKEY, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
r = RegCloseKey(keyhand)
End Sub


Function getdword(ByVal HKEY As Long, ByVal strPath As String, ByVal strValueName As String) As Long
Dim lResult As Long
Dim lValueType As Long
Dim lBuf As Long
Dim lDataBufSize As Long
Dim r As Long
Dim keyhand As Long

r = RegOpenKey(HKEY, strPath, keyhand)

' Get length/data type
lDataBufSize = 4

lResult = RegQueryValueEx(keyhand, strValueName, 0&, lValueType, lBuf, lDataBufSize)

If lResult = ERROR_SUCCESS Then
If lValueType = REG_DWORD Then
getdword = lBuf
End If
'Else
' Call errlog("GetDWORD-" & strPath, False)
End If

r = RegCloseKey(keyhand)

End Function

Function SaveDword(ByVal HKEY As Long, ByVal strPath As String, ByVal strValueName As String, ByVal lData As Long)
Dim lResult As Long
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(HKEY, strPath, keyhand)
lResult = RegSetValueEx(keyhand, strValueName, 0&, REG_DWORD, lData, 4)
'If lResult <> error_success Then Call errlog("SetDWORD", False)
r = RegCloseKey(keyhand)
End Function

Public Function DeleteKey(ByVal HKEY As Long, ByVal strKey As String)
Dim r As Long
r = RegDeleteKey(HKEY, strKey)
End Function

Public Function DeleteValue(ByVal HKEY As Long, ByVal strPath As String, ByVal strValue As String)
Dim keyhand As Long
r = RegOpenKey(HKEY, strPath, keyhand)
r = RegDeleteValue(keyhand, strValue)
r = RegCloseKey(keyhand)
End Function

最后作如下调用:
HKEY = HKEY_CURRENT_USER
strPath="Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
strValue = "HideFileExt"
strdata = 0
Call SaveDword(HKEY, strPath, strValue, strdata)
qhzxcz 2002-06-17
  • 打赏
  • 举报
回复
马上来解决
KAIBate 2002-06-17
  • 打赏
  • 举报
回复
关注!
wgku 2002-06-17
  • 打赏
  • 举报
回复
要用注册表操作吧??

勾上“隐藏文件后缀名”与取消“隐藏文件后缀名”时各保存一次系统注册表文件,然后和再用FC命令比较。

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧