2005년 12월 18일 일요일

Asp. 디스크 용량 모니터링

<%
        Set FileSystemObject = Server.CreateObject("Scripting.FileSystemObject")

        Set Drives = FileSystemObject.Drives

        For Each DiskDrive in Drives

                If DiskDrive.IsReady Then


                        totalspace = DiskDrive.TotalSize
                        freespace = DiskDrive.FreeSpace
                        usedspace = totalspace - freespace

                        freepercent = Int((freespace/totalspace)*100)
                        freemb = Int((freespace/1024)/1024)
                        usedmb = Int((usedspace/1024)/1024)
                        usedpercent = Int((usedspace/totalspace)*100)

                        If freespace =< 1048576 Then
                                freelabel = FormatNumber(freespace/1024, 1) & "
Kb"
                        Elseif freespace =< 1073741824 then
                                freelabel = FormatNumber((freespace/1024)/1024, 1) & "
Mb"
                        Else
                                freelabel = FormatNumber(((freespace/1024)/1024)/1024, 2) & "
Gb"
                        End If

                        If usedspace =< 1048576 Then
                                usedlabel = FormatNumber(usedspace/1024, 1) & "
Kb"
                        Elseif usedspace =< 1073741824 Then
                                usedlabel = FormatNumber((usedspace/1024)/1024, 1) & "
Mb"
                        Else
                                usedlabel = FormatNumber(((usedspace/1024)/1024)/1024, 2) & "
Gb"
                        End If

                        If Left(freelabel,3) = "0.0" Then freelabel = "
0 bytes"
                        If Left(usedlabel,3) = "0.0" Then usedlabel = "
0 bytes"

                        used_alt_tag = "
Drive " & DiskDrive.DriveLetter & ": " & usedlabel & " in use"
                        free_alt_tag = "
Drive " & DiskDrive.DriveLetter & ": " & freelabel & " free"

                        Response.Write "
Drive " & DiskDrive.DriveLetter & ": "

                        If DiskDrive.VolumeName <> "" then
                                Response.Write "
[" & DiskDrive.VolumeName & "] : "
                        End If

                        Response.Write "
<br>"
                End If
        Next

        Set Drives = nothing
        Set FileSystemObject = nothing
%>

위와 같은 디스크정보는 WMI를 통해서도 가능하다.
http://www.serverinfo.pe.kr/TipnTech.aspx?Content=Windows&Search=&vMode=View&page=&Seq=141

출처 : http://www.brettb.com/ASPDiskMonitoringScript.asp


C# Win32 API 이용해서 GUI 핸들 확인하기

키움증권 API 이용해서 직접 개발한 닷넷 기반 주식 자동 매매 GUI 프로그램의, 동작 모니터링과 자동 제어가 필요해서 위해서 참조했던 코드. 실행된 GUI 프로그램에서,  특정 핸들 개체(예를 들면 버튼)가 존재하는지 확인 후, 해당 개체에 ...