1 /*=============================================================================
\r
3 *
\82c
\82h
\82r
\82j
\82Ì
\83t
\83\8a\81[
\83X
\83y
\81[
\83X
\82ð
\93¾
\82é
\r
5 ===============================================================================
\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.
\r
8 / Redistribution and use in source and binary forms, with or without
\r
9 / modification, are permitted provided that the following conditions
\r
12 / 1. Redistributions of source code must retain the above copyright
\r
13 / notice, this list of conditions and the following disclaimer.
\r
14 / 2. Redistributions in binary form must reproduce the above copyright
\r
15 / notice, this list of conditions and the following disclaimer in the
\r
16 / documentation and/or other materials provided with the distribution.
\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
\r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
\r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
\r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
\r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
\r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
\r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
28 /============================================================================*/
\r
31 #include <windows.h>
\r
35 #include <mbstring.h>
\r
37 #include <windowsx.h>
\r
38 #include <winsock.h>
\r
41 #include "resource.h"
\r
44 typedef DWORD (WINAPI*FUNC_GETDISKFREESPACEEX) (LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
\r
46 /*=====
\83\8d\81[
\83J
\83\8b\82È
\83\8f\81[
\83N =====*/
\r
48 static HINSTANCE m_hDll = NULL;
\r
50 static FUNC_GETDISKFREESPACEEX m_GetDiskFreeSpaceEx = NULL;
\r
54 /*----- KERNEL32
\82ð
\83\8d\81[
\83h
\82·
\82é --------------------------------------------------
\r
61 *----------------------------------------------------------------------------*/
\r
63 void LoadKernelLib(void)
\r
65 OSVERSIONINFO VerInfo;
\r
67 VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
\r
68 GetVersionEx(&VerInfo);
\r
69 if(((VerInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) && (VerInfo.dwBuildNumber > 1000)) ||
\r
70 (VerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT))
\r
72 if((m_hDll = LoadLibrary("kernel32.dll")) != NULL)
\r
74 m_GetDiskFreeSpaceEx = (FUNC_GETDISKFREESPACEEX)GetProcAddress(m_hDll, "GetDiskFreeSpaceExA");
\r
76 if(m_GetDiskFreeSpaceEx == NULL)
\r
78 FreeLibrary(m_hDll);
\r
87 /*----- KERNEL32
\82ð
\83\8a\83\8a\81[
\83X
\82·
\82é -------------------------------------------------
\r
94 *----------------------------------------------------------------------------*/
\r
96 void ReleaseKernelLib(void)
\r
99 FreeLibrary(m_hDll);
\r
106 /*-----
\83t
\83\8a\81[
\83G
\83\8a\83A
\82Ì
\83T
\83C
\83Y
\82ð
\95\
\82í
\82·
\95¶
\8e\9a\97ñ
\82ð
\95Ô
\82·-------------------------------
\r
109 * char *Path :
\83p
\83X
\96¼
\r
112 * char *
\95¶
\8e\9a\97ñ
\r
113 *----------------------------------------------------------------------------*/
\r
115 char *AskLocalFreeSpace(char *Path)
\r
125 static char Buf[40];
\r
128 if(*(Path+1) == ':')
\r
130 strncpy(Buf, Path, 2);
\r
131 strcpy(Buf+2, "\\");
\r
133 if(m_GetDiskFreeSpaceEx != NULL)
\r
135 if((*m_GetDiskFreeSpaceEx)(Buf, &a, &b, &c) != 0)
\r
137 _ui64toa(a.QuadPart, Buf, 10);
\r
139 MakeSizeString(Free, Buf);
\r
146 if(GetDiskFreeSpace(Buf, &SectClus, &ByteSect, &FreeClus, &AllClus) == TRUE)
\r
148 Free = SectClus * ByteSect * FreeClus;
\r
149 MakeSizeString(Free, Buf);
\r