资源描述:
《如何在 windows操作系统中改变文件打开方式》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、如何在Windows操作系统中改变文件打开方式关键词:在oudle1。 3、在Moudle1“通用椛鳌辈糠稚鰽PI函数和常量。ConstREG_SZ=1GlobalConstHKEY_CLASSES_ROOT=H80000000DeclareFunctionOSRegQueryValueExLib"advapi32"Alias"RegQueryValueExA"(ByValhKeyAsLong,ByVallpszValueNameAsString,ByValdeAsString,ByValdlResu
2、ltAsLongOnErrorGoTo0'关闭错误陷阱lResult=OSRegOpenKey(hKey,lpszSubKey,phkResult)IflResult=0ThenRegOpenKey=TrueElseRegOpenKey=FalseEndIfEndFunctionFunctionRegSetStringValue(ByValhKeyAsLong,ByValstrValueNameAsString,ByValstrDataAsString,OptionalByValfLog)AsBooleanD
3、imlResultAsLongOnErrorGoTo0lResult=OSRegSetValueEx(hKey,strValueName,0,REG_SZ,ByValstrData,LenB(StrConv(strData,vbFromUnicode))+1)IflResult=0ThenRegSetStringValue=TrueElseRegSetStringValue=FalseEndIfEndFunctionFunctionStripTerminator(ByValstrStringAsString)
4、AsStringDimintZeroPosAsIntegerintZeroPos=InStr(strString,Chr$(0))IfintZeroPos>0ThenStripTerminator=Left$(strString,intZeroPos-1)ElseStripTerminator=strStringEndIfEndFunctionFunctionRegQueryStringValue(ByValhKeyAsLong,ByValstrValueNameAsString,strDataAsSt
5、ring)AsBooleanDimlResultAsLongDimlValueTypeAsLongDimstrBufAsStringDimlDataBufSizeAsLong RegQueryStringValue=FalseOnErrorGoTo0lResult=OSRegQueryValueEx(hKey,strValueName,0,lValueType,ByVal0,lDataBufSize)IflResult=ERROR_SUCCESSThenIflValueType=REG_SZThenstrBu
6、f=String(lDataBufSize,"")lResult=OSRegQueryValueEx(hKey,strValueName,0,0,ByValstrBuf,lDataBufSize)IflResult=ERROR_SUCCESSThenRegQueryStringValue=TruestrData=StripTerminator(strBuf)EndIfEndIfEndIfEndFunction 5、双击mand1,编写Click事件代码。PrivateSubmand1_Click()Dimh
7、KeyAsLongDimMyReturnAsLongDimMyDataAsStringMyReturn=OSRegOpenKey(HKEY_CLASSES_ROOT,".exc",hKey)MyReturn=RegQueryStringValue(hKey,"",MyData)MyReturn=OSRegOpenKey(HKEY_CLASSES_ROOT,MyData+"shellopenmand",hKey)MyReturn=RegSetStringValue(hKey,"","c:visio.ex
8、e1%",False)IfMyReturnThenMsgBox"改变文件打开方式成功!",vbInformation,"请注意"ElseMsgBox"改变文件打开方式失败!",vbExclamation,"请注意"EndIfOSRegCloseKey(hKey)EndSub 6、按F5运行程序,在简体中文yRegistry:TRegINIFile;Return:string;begintryMyR