Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to read and write VB.NET INI files

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to read and write VB.NET INI files, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Since the birth of the registry, the ini file is gradually losing its market share. However, based on the independence of the ini file, it has not yet reached the stage of withdrawal from the historical stage. Many application initialization and some interface parameters settings are still very willing to read from the ini file. In order to ensure that the operation needs parameters to read the ini file clearly, it is recommended to use a module to complete this work. Note: all operations are done by calling the standard WinAPI function. Read and write VB.NET INI file example code:

DimRetAsLong DimStartAsLong PublicFileNameAsString ConstBufSize=10240 DimbufAsString*BufSize PrivateDeclareFunctionGetPrivateProfileIntLib "kernel32" Alias "GetPrivateProfileIntA" (ByVallpApplicationNameAsString,ByVallpKeyNameAsString,ByValnDefaultAsLong,ByVallpFileNameAsString) AsLong PrivateDeclareFunctionGetPrivateProfileSectionLib "kernel32" Alias "GetPrivateProfileSectionA" (ByVallpAppNameAsString,ByVallpReturnedStringAsString,ByValnSizeAsLong,ByVallpFileNameAsString) AsLong PrivateDeclareFunctionGetPrivateProfileStringLib "kernel32" Alias "GetPrivateProfileStringA" (ByVallpApplicationNameAsString,ByVallpKeyNameAsAny,ByVallpDefaultAsString,ByVallpReturnedStringAsString,ByValnSizeAsLong,ByVallpFileNameAsString) AsLong PrivateDeclareFunctionWritePrivateProfileSectionLib "kernel32" Alias "WritePrivateProfileSectionA" (ByVallpAppNameAsString,ByVallpStringAsString,ByVallpFileNameAsString) AsLong PrivateDeclareFunctionWritePrivateProfileStringLib "kernel32" Alias "WritePrivateProfileStringA" (ByVallpApplicationNameAsString,ByVallpKeyNameAsAny,ByVallpStringAsAny,ByVallpFileNameAsString) AsLong PublicSubSetValue (ByValclsNameAsString,ByValkeyAsString,ByValVAsString) Ret=WritePrivateProfileString FileName) EndSub PublicFunctionGetValue (ByValclsNameAsString,ByValkeyAsString) AsString Ret=GetPrivateProfileString (clsName,key, ", buf,BufSize,FileName) Start=1 GetValue=RetStr () EndFunction PrivateFunctionRetStr () AsString DimiAsLong i=InStr (Start,buf,Chr (0)) Ifi > StartThen RetStr=Mid (buf,Start,i-Start) EndIf Start=i+1 EndFunction Thank you for reading this article carefully I hope the article "how to read and write VB.NET INI documents" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report