;[ 確認済み ] ;fxshort var p1, str file ;fxtget array p1, str file ;fxdir var p1, int p2 ;fxinfo var p1, int p2, int p3 ※1 ;fxren var p1, str new_name ;[ 未確認 ] ;fxtset var p1, str file ;fxaget var p1, str file ;fxaset str file, int p1 ;fxcopy var p1, str dest, int p2 ;[ 未実装 ] ;fxlink var p1, str path ;fxinfo var p1, int p2, 0(32) ;※1:2GB以上の取得 #ifdef __hsp30__ #ifndef __KERNEL32__ #define global __KERNEL32__ #uselib "KERNEL32.DLL" #define global GetFileAttributes GetFileAttributesA #func global GetFileAttributesA "GetFileAttributesA" sptr #func global GetFileAttributesW "GetFileAttributesW" sptr #define global SetFileAttributes SetFileAttributesA #func global SetFileAttributesA "SetFileAttributesA" sptr,sptr #func global SetFileAttributesW "SetFileAttributesW" sptr,sptr #define global CopyFile CopyFileA #func global CopyFileA "CopyFileA" sptr,sptr,sptr #func global CopyFileW "CopyFileW" sptr,sptr,sptr #define global MoveFile MoveFileA #func global MoveFileA "MoveFileA" sptr,sptr #func global MoveFileW "MoveFileW" sptr,sptr #define global GetDriveType GetDriveTypeA #func global GetDriveTypeA "GetDriveTypeA" sptr #func global GetDriveTypeW "GetDriveTypeW" sptr #define global GetSystemDirectory GetSystemDirectoryA #func global GetSystemDirectoryA "GetSystemDirectoryA" sptr,sptr #func global GetSystemDirectoryW "GetSystemDirectoryW" sptr,sptr #define global GetTempPath GetTempPathA #func global GetTempPathA "GetTempPathA" sptr,sptr #func global GetTempPathW "GetTempPathW" sptr,sptr #define global GetShortPathName GetShortPathNameA #func global GetShortPathNameA "GetShortPathNameA" sptr,sptr,sptr #func global GetShortPathNameW "GetShortPathNameW" sptr,sptr,sptr #define global GetDiskFreeSpace GetDiskFreeSpaceA #func global GetDiskFreeSpaceA "GetDiskFreeSpaceA" sptr,sptr,sptr,sptr,sptr #func global GetDiskFreeSpaceW "GetDiskFreeSpaceW" sptr,sptr,sptr,sptr,sptr #define global GetVolumeInformation GetVolumeInformationA #func global GetVolumeInformationA "GetVolumeInformationA" sptr,sptr,sptr,sptr,sptr,sptr,sptr,sptr #func global GetVolumeInformationW "GetVolumeInformationW" sptr,sptr,sptr,sptr,sptr,sptr,sptr,sptr #func global SetFileTime "SetFileTime" sptr,sptr,sptr,sptr #func global GetFileTime "GetFileTime" sptr,sptr,sptr,sptr #func global FileTimeToSystemTime "FileTimeToSystemTime" sptr,sptr #func global SystemTimeToFileTime "SystemTimeToFileTime" sptr,sptr #func global FileTimeToLocalFileTime "FileTimeToLocalFileTime" sptr,sptr #func global LocalFileTimeToFileTime "LocalFileTimeToFileTime" sptr,sptr #define global CreateFile CreateFileA #func global CreateFileA "CreateFileA" sptr,sptr,sptr,sptr,sptr,sptr,sptr #func global CreateFileW "CreateFileW" sptr,sptr,sptr,sptr,sptr,sptr,sptr #func global CloseHandle "CloseHandle" sptr #endif #ifndef __SHELL32__ #define global __SHELL32__ #uselib "SHELL32.DLL" #func global SHGetSpecialFolderLocation "SHGetSpecialFolderLocation" sptr,sptr,sptr ; #func global SHGetMalloc "SHGetMalloc" sptr #func global SHGetPathFromIDList "SHGetPathFromIDList" sptr,sptr #endif #ifndef __OLE32__ #define global __OLE32__ #uselib "OLE32.dll" #func global CoTaskMemFree "CoTaskMemFree" sptr #endif #endif #define global FILE_ATTRIBUTE_READONLY $0001 ;読み取り専用 #define global FILE_ATTRIBUTE_HIDDEN $0002 ;隠しファイル(or 隠しディレクトリ) #define global FILE_ATTRIBUTE_SYSTEM $0004 ;オペレーティングシステム専用 #define global FILE_ATTRIBUTE_DIRECTORY $0010 ;ディレクトリ(フォルダ) #define global FILE_ATTRIBUTE_ARCHIVE $0020 ;アーカイブ #define global FILE_ATTRIBUTE_ENCRYPTED $0040 ;暗号化 #define global FILE_ATTRIBUTE_NORMAL $0080 ;属性なし(単独の場合のみ有効) #define global FILE_ATTRIBUTE_TEMPORARY $0100 ;一時ファイルとして使われている #define global FILE_ATTRIBUTE_SPARSE_FILE $0200 ;スパースファイル(?) #define global FILE_ATTRIBUTE_REPARSE_POINT $0400 ;再解析ポイントが関連付けられている #define global FILE_ATTRIBUTE_COMPRESSED $0800 ;圧縮されている #define global FILE_ATTRIBUTE_OFFLINE $1000 ;(Windows 2000) すぐには利用できません(?) #define global FILE_ATTRIBUTE_NOT_CONTENT_INDEXED $2000 ;(Windows 2000) [インデックスサービス] の対象ではない #define global CSIDL_DESKTOP 0x0000 ;「デスクトップ」(ネームスペースのルートを表す仮想フォルダ) #define global CSIDL_INTERNET 0x0001 ;「Internet Explorer」(仮想フォルダ) #define global CSIDL_PROGRAMS 0x0002 ;「プログラム」(ファイルシステムディレクトリ) #define global CSIDL_CONTROLS 0x0003 ;「コントロール パネル」(仮想フォルダ) #define global CSIDL_PRINTERS 0x0004 ;「プリンタ」(仮想フォルダ) #define global CSIDL_PERSONAL 0x0005 ;「マイ ドキュメント」(ファイルシステムディレクトリ) #define global CSIDL_FAVORITES 0x0006 ;「お気に入り」(ファイルシステムディレクトリ) #define global CSIDL_STARTUP 0x0007 ;「スタートアップ」(ファイルシステムディレクトリ) #define global CSIDL_RECENT 0x0008 ;「最近使ったファイル」(ファイルシステムディレクトリ) #define global CSIDL_SENDTO 0x0009 ;「SendTo」(ファイルシステムディレクトリ) #define global CSIDL_BITBUCKET 0x000a ;「ごみ箱」(仮想フォルダ) #define global CSIDL_STARTMENU 0x000b ;「スタートメニュー」(ファイルシステムディレクトリ) #define global CSIDL_MYMUSIC 0x000d ;「マイ ミュージック」(ファイルシステムディレクトリ) #define global CSIDL_DESKTOPDIRECTORY 0x0010 ;「デスクトップ」上のファイルオブジェクトを格納するフォルダ(ファイルシステムディレクトリ) #define global CSIDL_DRIVES 0x0011 ;「マイ コンピュータ」(仮想フォルダ) #define global CSIDL_NETWORK 0x0012 ;「ネットワークコンピュータ」(仮想フォルダ) #define global CSIDL_NETHOOD 0x0013 ;「NetHood」(ファイルシステムディレクトリ) #define global CSIDL_FONTS 0x0014 ;「Fonts」(フォントを含む仮想フォルダ) #define global CSIDL_TEMPLATES 0x0015 ;ドキュメントテンプレートが格納されるフォルダ(ファイルシステムディレクトリ) #define global CSIDL_COMMON_STARTMENU 0x0016 ;AllUsers の「スタートメニュー」(ファイルシステムディレクトリ) #define global CSIDL_COMMON_PROGRAMS 0x0017 ;AllUsers の「プログラム」(ファイルシステムディレクトリ) #define global CSIDL_COMMON_STARTUP 0x0018 ;AllUsers の「スタートアップ」(ファイルシステムディレクトリ) #define global CSIDL_COMMON_DESKTOPDIRECTORY 0x0019 ;AllUsers の「デスクトップ」(ファイルシステムディレクトリ) #define global CSIDL_APPDATA 0x001a ;Ver 4.71 〜: 「Application Data」(ファイルシステムディレクトリ) #define global CSIDL_PRINTHOOD 0x001b ;「プリンタ」仮想フォルダにおかれるリンクオブジェクトを格納するフォルダ(ファイルシステムディレクトリ) #define global CSIDL_LOCAL_APPDATA 0x001c ;Ver 5.0 〜: 「Application Data」(ファイルシステムディレクトリ) #define global CSIDL_ALTSTARTUP 0x001d ;非ローカル版の「スタートアップ」(ファイルシステムディレクトリ) #define global CSIDL_COMMON_ALTSTARTUP 0x001e ;非ローカル版の AllUsers の「スタートアップ」(ファイルシステムディレクトリ) #define global CSIDL_COMMON_FAVORITES 0x001f ;AllUsers の「お気に入り」(NT系のみ)(ファイルシステムディレクトリ) #define global CSIDL_INTERNET_CACHE 0x0020 ;Ver 4.72 〜: インターネット一時ファイルを格納するフォルダ(ファイルシステムディレクトリ) #define global CSIDL_COOKIES 0x0021 ;「Cookies」(ファイルシステムディレクトリ) #define global CSIDL_HISTORY 0x0022 ;「履歴」(ファイルシステムディレクトリ) #define global CSIDL_COMMON_APPDATA 0x0023 ;Ver 5.0 〜: AllUsers の「Application Data」(ファイルシステムディレクトリ) #define global CSIDL_WINDOWS 0x0024 ;Ver 5.0 〜: Windows ディレクトリ #define global CSIDL_SYSTEM 0x0025 ;Ver 5.0 〜: Windows System ディレクトリ #define global CSIDL_PROGRAM_FILES 0x0026 ;Ver 5.0 〜: Program Files フォルダ #define global CSIDL_MYPICTURES 0x0027 ;Ver 5.0 〜: My Pictures フォルダ(ファイルシステムディレクトリ) #define global CSIDL_PROFILE 0x0028 ;Ver 5.0 〜: profile フォルダ #define global CSIDL_PROGRAM_FILES_COMMON 0x002b ;Ver 5.0 〜;Windows 2000/XP: Program Files\Common #define global CSIDL_COMMON_TEMPLATES 0x002d ;Windows NT/2000/XP: AllUsers のドキュメントテンプレートが格納されるディレクトリ #define global CSIDL_COMMON_DOCUMENTS 0x002e ;Shfolder.dll: AllUsers のドキュメントテンプレートが格納されるディレクトリ(Windows NT 系および Shfolder.dll がインストールされた Windows 9x) #define global CSIDL_COMMON_ADMINTOOLS 0x002f ;Ver 5.0 〜: AllUsers の管理ツールディレクトリ #define global CSIDL_ADMINTOOLS 0x0030 ;Ver 5.0 〜: 管理ツールディレクトリ #module ;[ 使用変数 ] ; fxdir : pidl、stt ; fxtget : hfile、num、date、stt、time、off ; fxtset : hfile、num、date、stt、time、off ; fxinfo : drive、num、data ;---------- ---------- ---------- ---------- ---------- ; ファイル属性を取得 ;---------- ---------- ---------- ---------- ---------- #deffunc fxaget var p1, str file GetFileAttributes file if( stat == -1 ): return 1 p1 = stat return 0 ;---------- ---------- ---------- ---------- ---------- ; ファイル属性を設定 ;---------- ---------- ---------- ---------- ---------- #deffunc fxaset str file, int p1 SetFileAttributes file, p1 if( stat == 0 ): return 1 return 0 ;---------- ---------- ---------- ---------- ---------- ; ファイルのコピー・移動 ;---------- ---------- ---------- ---------- ---------- #deffunc fxcopy var p1, str dest, int p2 CopyFile varptr(p1), dest, 1 if( stat == 0 ): return 1 ;失敗 if( p2 > 0 ){ ; p2 = 1 の場合は「ファイルの移動」になるので exist p1 : if( strsize > -1 ): delete p1 } return 0 ;---------- ---------- ---------- ---------- ---------- ; 特殊なディレクトリ名を取得 ;---------- ---------- ---------- ---------- ---------- #deffunc fxdir var p1, int p2 if( p2 >= 0 ){ stt = 1 ; ディレクトリ名を取得 SHGetSpecialFolderLocation hwnd, p2, varptr(pidl) if( stat == 0 ){ ; パスに変換する SHGetPathFromIDList pidl, varptr(p1) if( stat == 0 ): stt = 0 } ; 取得したIDLを解放 CoTaskMemFree pidl return stt } ; Windowsのテンポラリ(一時)フォルダ if( p2 == -2 ){ GetTempPath 260, varptr(p1) } ; Windowsのシステム(System)フォルダ if( p2 == -1 ){ GetSystemDirectory varptr(p1), 260 } if( stat == 0 ): return 1 return 0 ;---------- ---------- ---------- ---------- ---------- ; ドライブ情報を取得 ;---------- ---------- ---------- ---------- ---------- #deffunc fxinfo var p1, int p2, int p3 ; ドライブ名の設定 drive = "A:\\" : poke drive, 0, p2+64 ; ドライブの空き容量など if(( p3 >= 0 )&&( p3 <= 4 ))||( p3 == 32 ){ dim data, 5 : num = varptr(data)+4 GetDiskFreeSpace drive, num, num+4, num+8, num+12 if( stat == 0 ): return 1 ; 2GB を越え、p3=0 の場合は、 -1 を返すべき ; 2GB 以上は、64バイト変数を使用しなければ無理 data = data.2 * data.1 * data.3 if( p3 == 32 ){ p1 = strf("%u", data) } else { p1 = data( p3 ) } return 0 } ; ドライブのタイプを取得 if( p3 == 8 ){ GetDriveType drive : p1 = stat return 0 } ; ドライブの名前とか if( p3 == 16 ): GetVolumeInformation drive, varptr(p1),260, 0,0,0,0,0 if( p3 == 17 ): GetVolumeInformation drive, 0,0,0,0,0, varptr(p1),260 if( p3 == 18 ): GetVolumeInformation drive, 0,0, varptr(p1) ,0,0,0,0 if( p3 == 19 ): GetVolumeInformation drive, 0,0,0, varptr(p1) ,0,0,0 if( p3 == 20 ): GetVolumeInformation drive, 0,0,0,0, varptr(p1) ,0,0 if( stat == 0 ): return 1 return 0 ;---------- ---------- ---------- ---------- ---------- ; ショートカットを作成 ;---------- ---------- ---------- ---------- ---------- #deffunc fxlink var p1, str path return ;---------- ---------- ---------- ---------- ---------- ; ファイル名を変更 ;---------- ---------- ---------- ---------- ---------- #deffunc fxren var p1, str new_name MoveFile varptr(p1), new_name if( stat == 0 ): return 1 ;失敗 return 0 ;---------- ---------- ---------- ---------- ---------- ; DOSファイルネームを取得 ;---------- ---------- ---------- ---------- ---------- #deffunc fxshort var p1, str file GetShortPathName file, varptr(p1), 260 return ;---------- ---------- ---------- ---------- ---------- ; タイムスタンプを取得 ;---------- ---------- ---------- ---------- ---------- #deffunc fxtget array p1, str file ; ファイルのハンドルを取得 CreateFile file, $80000000, 0, 0, 3, $80, 0 if( stat == 0 ): return 1 hfile = stat dim time,6 : stt = 1 dim date,8 : off = varptr(time) ; 時間を取得 GetFileTime hfile, off, off+16, off+8 if( stat != 0 ){ stt = 0 repeat 3 ; 自分のパソコンの時間に変換 FileTimeToLocalFileTime off, off if( stat == 0 ): stt = 1 : break ; システムタイムに変換 FileTimeToSystemTime off, varptr(date) if( stat == 0 ): stt = 1 : break ; 変数に格納 num = 0 repeat 8, cnt*8 p1(cnt) = wpeek(date,num) num += 2 loop off += 8 loop } ; ファイルを閉じる CloseHandle hfile return stt ;---------- ---------- ---------- ---------- ---------- ; タイムスタンプを設定 ;---------- ---------- ---------- ---------- ---------- #deffunc fxtset var p1, str file ; ファイルのハンドルを取得 CreateFile file, $40000000, 0, 0, 3, $80, 0 if( stat == 0 ): return 1 hfile = stat dim time,6 : stt = 0 dim date,8 : off = varptr(time) repeat 3 ; 変数に格納 num = 0 repeat 8, cnt*8 p1(cnt) = wpeek(date,num) num += 2 loop ; システムタイムに変換 SystemTimeToFileTime varptr(date), off if( stat == 0 ): stt = 1 : break off += 8 ; 自分のパソコンの時間に変換 LocalFileTimeToFileTime off, off if( stat == 0 ): stt = 1 : break loop if( stt == 0 ){ ; 時間を設定 SetFileTime hfile, off, off+16, off+8 if( stat == 0 ): stt = 1 } ; ファイルを閉じる CloseHandle hfile return stt ;---------- ---------- ---------- ---------- ---------- #global