资源描述:
《vb创建自定义文件后缀名,并改变其默认图标及打开方式》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、VB创建自定义文件后缀名,并改变其默认图标及打开方式VB创建自定义文件后缀名,并改变其默认图标及打开方式2010-11-3011:43网上下的一个程序,可以用它来打造自己的工程品牌!这里我把原代码贴出,希望对大家有所帮助!标准模块:General.basAttributeVB_Name="General"PublicConstREG_SZ=1GlobalConstHKEY_CLASSES_ROOT=&H80000000PublicDeclareFunctionRegCreateKeyLib"advapi32.dll"Alias"RegCreateKeyA"(ByVal
2、hKeyAsLong,ByVallpSubKeyAsString,phkResultAsLong)AsLongDeclareFunctionRegQueryValueExLib"advapi32"Alias"RegQueryValueExA"(ByValhKeyAsLong,ByVallpszValueNameAsString,ByValdwReservedAsLong,lpdwTypeAsLong,lpbDataAsAny,cbDataAsLong)AsLongDeclareFunctionRegOpenKeyLib"advapi32"Alias"RegOpenKe
3、yA"(ByValhKeyAsLong,ByVallpszSubKeyAsString,phkResultAsLong)AsLongDeclareFunctionRegSetValueExLib"advapi32.dll"Alias"RegSetValueExA"(ByValhKeyAsLong,ByVallpValueNameAsString,ByValReservedAsLong,ByValdwTypeAsLong,lpDataAsAny,ByValcbDataAsLong)AsLong'NotethatifyoudeclarethelpDataparameter
4、asString,youmustpassitByValue.DeclareFunctionRegCloseKeyLib"advapi32"(ByValhKeyAsLong)AsLongPublicDeclareFunctionGetSystemDirectoryLib"kernel32"Alias"GetSystemDirectoryA"(ByVallpBufferAsString,ByValnSizeAsLong)AsLongPublicFunctionRegSetStringValue(ByValhKeyAsLong,ByValstrValueNameAsStri
5、ng,_ByValstrDataAsString,OptionalByValfLog)AsBooleanDimlResultAsLongOnErrorGoTo0lResult=RegSetValueEx(hKey,strValueName,0&,REG_SZ,ByValstrData,_LenB(StrConv(strData,vbFromUnicode))+1)IflResult=0ThenRegSetStringValue=TrueElseRegSetStringValue=FalseEndIfEndFunctionPublicFunctionStripTermi
6、nator(ByValstrStringAsString)AsStringDimintZeroPosAsIntegerintZeroPos=InStr(strString,Chr$(0))IfintZeroPos0ThenStripTerminator=Left$(strString,intZeroPos-1)ElseStripTerminator=strStringEndIfEndFunctionPublicFunctionRegQueryStringValue(ByValhKeyAsLong,ByValstrValueNameAsString,_strDataAs
7、String)AsBooleanDimlResultAsLongDimlValueTypeAsLongDimstrBufAsStringDimlDataBufSizeAsLongRegQueryStringValue=FalseOnErrorGoTo0lResult=RegQueryValueEx(hKey,strValueName,0&,lValueType,ByVal0&,_lDataBufSize)IflResult=ERROR_SUCCESSThenIflValueType=REG_SZThenstrBuf=String(lDataBufSi