偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

迅速掌握VB.NET讀取INI文件操作方法

開發(fā) 后端
VB.NET讀取INI文件的相關(guān)操作方法對(duì)于初學(xué)者來說應(yīng)該還是比較容易掌握的。我們可以通過本文介紹的具體代碼編寫來具體了解其中的操作技巧。

VB.NET做為一款***的開發(fā)平臺(tái),為開發(fā)人員帶來了很大的幫助。因?yàn)閷?duì)XML前不了解,所以對(duì)XML方式來做配置文件我都不能很好的實(shí)現(xiàn),但為了應(yīng)行,只有先使用INI的文來記錄了,也就沿用了VB6里的INI文讀取方法。#t#

下面請(qǐng)看VB.NET讀取INI文件的相關(guān)代碼示例:

 

  1. '聲明INI配置文件讀寫API函數(shù)  
  2. Private Declare Function GetPrivateProfileString()
    Function GetPrivateProfileString Lib "kernel32" 
    Alias "GetPrivateProfileStringA" (ByVal 
    lpApplicationName As String, ByVal lpKeyName As 
    String, ByVal lpDefault As String, ByVal lpReturned
    String As String, ByVal nSize As Int32, ByVal 
    lpFileName As String) As Int32  
  3. Private Declare Function WritePrivateProfileString()
    Function WritePrivateProfileString Lib "kernel32" 
    Alias "WritePrivateProfileStringA" (ByVal 
    lpApplicationName As String, ByVal lpKeyName As 
    String, ByVal lpString As String, ByVal lpFileName 
    As String) As Int32  
  4. '定義讀取配置文件函數(shù)  
  5. Public Function GetINI()Function GetINI(ByVal 
    Section As String, ByVal AppName As String, ByVal 
    lpDefault As String, ByVal FileName As String) 
    As String  
  6. Dim Str As String = LSet(Str, 256)  
  7. GetPrivateProfileString(Section, AppName, 
    lpDefault, Str, Len(Str), FileName)  
  8. Return Microsoft.VisualBasic.Left(Str, InStr
    (Str, Chr(0)) - 1)  
  9. End Function  
  10. '定義寫入配置文件函數(shù)  
  11. Public Function WriteINI()Function WriteINI
    (ByVal Section As String, ByVal AppName As 
    String, ByVal lpDefault As String, ByVal 
    FileName As String) As Long  
  12. WriteINI = WritePrivateProfileString(Section, 
    AppName, lpDefault, FileName)  
  13. End Function  
  14. Private Sub Form1_Load()Sub Form1_Load(ByVal 
    sender As System.Object, ByVal e As System.
    EventArgs) Handles MyBase.Load  
  15. Dim path As String  
  16. path = Application.StartupPath + "\server.ini"  
  17. TextBox1.Text = GetINI("Server", "IP", "", path)  
  18. TextBox2.Text = GetINI("Server", "port", "", path)  
  19. End Sub  
  20. Private Sub Button1_Click()Sub Button1_Click
    (ByVal sender As System.Object, ByVal e As 
    System.EventArgs) Handles Button1.Click  
  21. Try  
  22. Dim path As String  
  23. path = Application.StartupPath + "\server.ini"  
  24. WriteINI("Server", "IP", TextBox1.Text, path)  
  25. WriteINI("Server", "port", TextBox2.Text, path)  
  26. MsgBox("配置設(shè)置已經(jīng)成功?。。?!")  
  27. Me.Close()  
  28. Catch ex As Exception  
  29. MsgBox("錯(cuò)誤!!??!")  
  30. End Try  
  31. End Sub 

VB.NET讀取INI文件的相關(guān)操作就為大家介紹到這里。

責(zé)任編輯:曹凱 來源: 博客園
相關(guān)推薦

2010-01-11 10:34:41

VB.NET圖像操作

2010-01-11 14:28:14

VB.NET操作Exc

2010-01-12 10:19:02

VB.NET操作GDI

2009-10-29 13:38:05

VB.NET Shar

2009-10-15 16:39:00

VB.NET讀取INI

2010-01-11 15:43:06

VB.NET類屬性

2010-01-07 10:28:04

VB.NET實(shí)現(xiàn)接口

2010-01-21 15:56:31

VB.NET文本框

2010-01-07 10:46:27

VB.NET Sock

2010-01-20 13:42:10

VB.NET訪問INIGetPrivateP

2009-11-02 10:53:34

VB.NET INI文

2010-01-15 17:51:51

VB.NET創(chuàng)建臨時(shí)文

2010-01-07 15:37:35

VB.NET ForNext循環(huán)

2009-10-30 16:40:04

VB.NET Inte

2010-01-13 17:47:59

VB.NET拖放

2010-01-08 18:10:44

VB.NET實(shí)現(xiàn)任務(wù)欄

2009-10-29 14:16:32

VB.NET讀寫文本文

2010-01-11 15:54:48

VB.NET操作縮放圖

2009-10-21 10:05:48

VB.NET Read

2010-01-14 10:07:08

VB.NET文件名排序
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)