关于getopt函数,getopt函数怎么用这个很多人还不知道,今天小深来为大家解答以上的问题,现在让我们一起来看看吧!
1、ar.h ftw.h libIDL-2.0 nlist.h startup-notification-1.0'API函数的声明'ini配置文件Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, _ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As LongPrivate Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, _ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long'自定义函数'读取/设置ini配置文件Private Function GetIniS(FilePath As String, SectionName As String, KeyWord As String, DefString As String) As StringDim ResultString As String 255, Temp As LongDim s As String, i As IntegerTemp = GetPrivateProfileString(SectionName, KeyWord, "", ResultString, 255, FilePath)If Temp > 0 Then '的值不为空s = ""For i = 1 To 255If Asc(Mid(ResultString, i, 1)) = 0 ThenExit ForElses = s & Mid(ResultString, i, 1)End IfNext iElse'将缺省值写入INI文件Temp = WritePrivateProfileString(SectionName, KeyWord, DefString, FilePath)End IfEnd IfGetIniS = sEnd FunctionDim d As Long, s As Stringd = DefValueGetIniN = GetPrivateProfileInt(SectionName, KeyWord, DefValue, FilePath)'If d <> DefValue Then' s = CStr(d)' d = WritePrivateProfileString(SectionName, KeyWord, s, FilePath)'End IfEnd FunctionPrivate Sub SetIniS(FilePath As String, SectionName As String, KeyWord As String, ValStr As String)Dim res As Longres = WritePrivateProfileString(SectionName, KeyWord, ValStr, FilePath)End SubPrivate Sub SetIniN(FilePath As String, SectionName As String, KeyWord As String, ValLon As Long)Dim res As Long, s As Stringres = WritePrivateProfileString(SectionName, KeyWord, s, FilePath)End Sub'读取过程Dim fname As StringDim SectionName As String, KeyWord As String, DefString As String, DefValue As LongDim s As String, sValue As StringDim i As Integer, j As IntegerDim Result() As Stringfname = "......" '你所要读取的文件(包括其路径)SectionName = "KeyName" '字段KeyWord = "Key" '相同的部分j = -1Doi = i + 1s = KeyWord & CStr(i)sValue = GetIniS(fname, SectionName, KeyWord, DefString)If sValue <> DefString Thenj = j + 1ReDim Preserve Resultexec.h jmorecfg.h ncurses.h security zutil.h(j)Result(j) = sValueElseExit DoEnd IfEnd Sub你再结合自己的具体情况,修改下就行了。
本文到这结束,希望上面文章对大家有所帮助。