找回密码
 加入
搜索
查看: 3126|回复: 4

[系统综合] [已解决]ini排序问题

[复制链接]
发表于 2010-4-14 12:32:47 | 显示全部楼层 |阅读模式
本帖最后由 jycel 于 2010-4-14 12:52 编辑

INI配置中,键名是一个一个写入的,全是计算名,值是IP地址 ,当上线一个机器就会写入
要处理的就是对键名按计算机名从小到大排序,麻烦大家给点意见!
格式如下:
[在线用户]
PC090=192.168.0.100
PC094=192.168.0.104
PC029=192.168.0.39
PC001=192.168.0.11
PC017=192.168.0.27

测试代码如下:
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <GuiConstantsEx.au3>
$user=@ScriptDir&"\user.ini"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 198, 352, 192, 114)
$ListView1 = GUICtrlCreateListView("", 16, 8, 161, 281, $WS_BORDER,$LVS_ICON)
GUICtrlSetBkColor(-1, 0x3A6EA5)
_GUICtrlListView_SetView($ListView1, 3);设置样式,可选(1、2、3、4)
$Button1 = GUICtrlCreateButton("排序", 8, 304, 169, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_duuser()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        
        EndSwitch
WEnd
Func _duuser()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
$var=IniReadSection($user,"在线用户")
If Not @error Then
For $i= 1 To $var[0][0]
GUICtrlCreateListViewItem($var[$i][0], $ListView1)
GUICtrlSetImage(-1,"shell32.dll",-19)
Next
EndIf
EndFunc

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-4-14 12:48:09 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiConstantsEx.au3>
#include <Array.au3>
$user = @ScriptDir & "\user.ini"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 198, 352, 192, 114)
$ListView1 = GUICtrlCreateListView("", 16, 8, 161, 281, $WS_BORDER, $LVS_ICON)
GUICtrlSetBkColor(-1, 0x3A6EA5)
_GUICtrlListView_SetView($ListView1, 3);设置样式,可选(1、2、3、4)
$Button1 = GUICtrlCreateButton("排序", 8, 304, 169, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_duuser()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        Sort()
        EndSwitch
WEnd
Func Sort()
        $var = IniReadSection($user, "在线用户")
        _ArraySort($var, 0, 1)
        IniWriteSection($user, "在线用户", $var)
        _duuser()
EndFunc   ;==>Sort
Func _duuser()
        _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
        $var = IniReadSection($user, "在线用户")
        If Not @error Then
                For $i = 1 To $var[0][0]
                        GUICtrlCreateListViewItem($var[$i][0], $ListView1)
                        GUICtrlSetImage(-1, "shell32.dll", -19)
                Next
        EndIf
EndFunc   ;==>_duuser
 楼主| 发表于 2010-4-14 12:53:07 | 显示全部楼层
学习了!谢谢afan
发表于 2010-4-14 13:32:38 | 显示全部楼层
太好了,刚好用上
发表于 2010-4-29 19:32:13 | 显示全部楼层
很好,留个记号!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-2 15:45 , Processed in 0.073387 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表