⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mswin.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 4 页
字号:
		Searches a directory for a file whose name matches the specified file name (wildcards
		are allowed). One can use this function in combination with FindNextFile and FindClose 
		to find all the files in the specified directory.
	Parameters:
		lpFileName = the wildcard pattern which the file name must match
		lpFindFileData = pointer to a structure WIN32_FIND_DATAA which will receive the information
						about each file
	Example:
		// a DOS dir command
		// can type into ScriptWindow "dir c:\*.*", for example.
		//
		void dir(string strFile)
		{
			WIN32_FIND_DATAA	find;
			HANDLE	hFile;

			//out_str(strFile);
			int	nCount = 0;
			
			if((hFile=FindFirstFile(strFile,&find)) != INVALID_HANDLE_VALUE)
			{
				out_str(find.cFileName);
				nCount++;
				while(FindNextFile(hFile,&find))
				{
					out_str(find.cFileName);
					nCount++;
				}
				printf("%d files found\n",nCount);
				FindClose(hFile);		// must close  the hadle
			}
			else
				printf("%s: file(s) not found\n",strFile);
		}
	SeeAlso:
		FindNextFile
*/
HANDLE WINAPI FindFirstFile(LPCSTR lpFileName, WIN32_FIND_DATAA *lpFindFileData);

/** >File Management
	SeeAlso:
		FindFirstFile
*/
BOOL WINAPI	FindNextFile(HANDLE hFindFile, WIN32_FIND_DATAA *lpFindFileData);

/** >File Management
	SeeAlso:
		FindFirstFile
*/
BOOL WINAPI	FindClose(HANDLE hFindFile);

typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
    DWORD dwFileAttributes;
    FILETIME ftCreationTime;
    FILETIME ftLastAccessTime;
    FILETIME ftLastWriteTime;
    DWORD nFileSizeHigh;
    DWORD nFileSizeLow;
} WIN32_FILE_ATTRIBUTE_DATA;

#define FILE_SHARE_READ                 0x00000001  
#define FILE_SHARE_WRITE                0x00000002  
#define FILE_SHARE_DELETE               0x00000004  
// dwFileAttributes are defined as follows
#define FILE_ATTRIBUTE_READONLY             0x00000001  
#define FILE_ATTRIBUTE_HIDDEN               0x00000002  
#define FILE_ATTRIBUTE_SYSTEM               0x00000004  
#define FILE_ATTRIBUTE_DIRECTORY            0x00000010  
#define FILE_ATTRIBUTE_ARCHIVE              0x00000020  
#define FILE_ATTRIBUTE_ENCRYPTED            0x00000040  
#define FILE_ATTRIBUTE_NORMAL               0x00000080  
#define FILE_ATTRIBUTE_TEMPORARY            0x00000100  
#define FILE_ATTRIBUTE_SPARSE_FILE          0x00000200  
#define FILE_ATTRIBUTE_REPARSE_POINT        0x00000400  
#define FILE_ATTRIBUTE_COMPRESSED           0x00000800  
#define FILE_ATTRIBUTE_OFFLINE              0x00001000  
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED  0x00002000  


#define GetFileAttributes  GetFileAttributesA
/** >File Management
		Retrieves given file attributes.
	Parameters:
		lpcszFilename = full pathname of the file.
	Return:
		a bitfield with the following possible bits:
		FILE_ATTRIBUTE_READONLY             0x00000001  
		FILE_ATTRIBUTE_HIDDEN               0x00000002  
		FILE_ATTRIBUTE_SYSTEM               0x00000004  
		FILE_ATTRIBUTE_DIRECTORY            0x00000010  
		FILE_ATTRIBUTE_ARCHIVE              0x00000020  
		FILE_ATTRIBUTE_ENCRYPTED            0x00000040  
		FILE_ATTRIBUTE_NORMAL               0x00000080  
		FILE_ATTRIBUTE_TEMPORARY            0x00000100  
		FILE_ATTRIBUTE_SPARSE_FILE          0x00000200  
		FILE_ATTRIBUTE_REPARSE_POINT        0x00000400  
		FILE_ATTRIBUTE_COMPRESSED           0x00000800  
		FILE_ATTRIBUTE_OFFLINE              0x00001000  
		FILE_ATTRIBUTE_NOT_CONTENT_INDEXED  0x00002000  
	Example:
		void	run_GetFileAttributes()
		{
			DWORD	dwAttributes = GetFileAttributes("c:\\config.sys");
			printf("File attributes are: %#x\n", dwAttributes);
		}
*/
DWORD WINAPI GetFileAttributes(LPCSTR lpcszFilename);

#define GetFileAttributesEx  GetFileAttributesExA
/**# File Management
		Retrieves attributes for a specified file or directory.
		It is similar to GetFileAttributes, but it returns more information - 
		in addition to attributes, it also returns various file times and file size.
	Parameters:
		lpcszFilename = full pathname of the file
		nInfoLevel = must be 0.
		lpFileInfo = pointer to the WIN32_FILE_ATTRIBUTE_DATA which will receive the information
					about the file:
					typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
					    DWORD dwFileAttributes;		// attributes (the same as for the function GetFileAttributes)
					    FILETIME ftCreationTime;	// creation time
					    FILETIME ftLastAccessTime;	// last access time
					    FILETIME ftLastWriteTime;	// last modification time
					    DWORD nFileSizeHigh;		// the high DWORD of the file size (it is zero unless the file is over four gigabytes)
					    DWORD nFileSizeLow;			// the low DWORD of thr file size
					} WIN32_FILE_ATTRIBUTE_DATA;
	Returns:
		Returns FALSE if file sepcified is not a valid file name or directory name
		Returns TRUE if succeed
	Examples:
		void run_GetFileAttributesEx(string filename)
		{
			WIN32_FILE_ATTRIBUTE_DATA	fileInfo;
		
			if(GetFileAttributesEx(filename, 0, &fileInfo))
			{
				int	nSize = fileInfo.nFileSizeLow;
				out_int("File size=", nSize);
			}
			else
				out_str("file not found");
		}
*/
BOOL WINAPI GetFileAttributesEx(
	LPCSTR lpcszFilename, 	  // file or directory
	int nInfoLevel, 		  // must be set to 0
	WIN32_FILE_ATTRIBUTE_DATA* lpFileInfo  // pointer to the structure
	);

#define SetFileAttributes  SetFileAttributesA
/** >File Management
		It sets file attributes.
	Parameters:
		lpcszFilename = full pathname of the file.
		dwFileAttributes = new attributes
	Return:
		nonzero if it succeeds, 0 if it fails.
	Example:
		// This example shows how to change file attributes of a file.
		// Note that the file c:\myfile.txt must exist for this example to run.
		void	run_SetFileAttributes()
		{
			string		strFile = "c:\\myfile.txt";
			
			// First get and display the old attributes:
			DWORD	dwAttributes = GetFileAttributes(strFile);
			printf("File attributes are: %#x\n", dwAttributes);
			
			// Change the attributes:
			SetFileAttributes(strFile, 0x22);
			
			// Display again:
			dwAttributes = GetFileAttributes(strFile);
			printf("File attributes are: %#x\n", dwAttributes);
		}
*/
BOOL WINAPI SetFileAttributes(LPCSTR lpcszFilename,DWORD dwFileAttributes); //set a file's attributes


//
// Routines to convert back and forth between system time and file time
//
/** >File Management
		Converts a 64-bit file time (in form of a FILETIME structure) to system time format.
	Parameters:
		lpFileTime = the pointer to the 64-bit file time (usually obtained from GetFileAttributesEx() function as one of the
						members of the WIN32_FILE_ATTRIBUTE_DATA structure).
		lpSystemTime = the pointer to the SYSTEMTIME structure which will receive the result. The members of SYSTEMTIME
						structure provide a human-readable form of date and time.
	Returns:
		nonzero for success, 0 for failure.
	Example:
		// The example displays system time of one file.
		// Note that the file c:\myfile.txt must exist for this example to run.
		void	run_FileTimeToSystemTime()
		{
			string						strFile = "c:\\myfile.txt";
			WIN32_FILE_ATTRIBUTE_DATA	fileInfo;
			// Get the attributes structure of the file
			if ( GetFileAttributesEx(strFile, 0, &fileInfo) )
			{
				SYSTEMTIME		stSystemTime;
				// Convert the last access time to SYSTEMTIME structure: 
				if ( FileTimeToSystemTime(&fileInfo.ftLastAccessTime, &stSystemTime) )
				{
					printf("Year = %d,  Month = %d,  Day = %d,  Hour = %d,  Minute = %d\n", stSystemTime.wYear, stSystemTime.wMonth, stSystemTime.wDay, stSystemTime.wHour, stSystemTime.wMinute);
				}
			}
			else
				out_str("Cannot get file attributes!");
		}


	SeeAlso:
		SystemTimeToFileTime
*/
BOOL WINAPI FileTimeToSystemTime(
    const FILETIME *lpFileTime,
    SYSTEMTIME* lpSystemTime
    );

/**# >File Management
	Converts a system time to 64-bit file time
	SeeAlso:
		SetFileTime
*/
BOOL WINAPI SystemTimeToFileTime(
    const SYSTEMTIME *lpSystemTime,
    FILETIME* lpFileTime
    );

/** >File Management
	This function sets the date and time that a file was created, last accessed, or last modified.
	Parameters
		hFile = [in] Handle to the file for which to set the dates and times. The file handle must have been created with GENERIC_WRITE access to the file. 
		lpCreationTime = [in] Pointer to a FILETIME structure that contains the date and time the file was created. This parameter can be NULL if the application does not need to set this information. 
		lpLastAccessTime = [in] Pointer to a FILETIME structure that contains the date and time the file was last accessed. The last access time includes the last time the file was written to, read from, or (in the case of executable files) run. This parameter can be NULL if the application does not need to set this information. 
		lpLastWriteTime = [in] Pointer to a FILETIME structure that contains the date and time the file was last written to. This parameter can be NULL if the application does not want to set this information. 
	Return:
		TRUE if success, FALSE if error
	Example:
		BOOL SetFileToCurrentTime(LPCSTR lpcszFilename)
		{
			BOOL bRet = FALSE;
			HANDLE hFile = CreateFile(lpcszFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
			if (hFile != INVALID_HANDLE_VALUE)
			{
				FILETIME ft;
				SYSTEMTIME st;
				GetSystemTime(&st);              // gets current time
				SystemTimeToFileTime(&st, &ft);  // converts to file time format
				bRet = SetFileTime(hFile,NULL, NULL, &ft);
				CloseHandle(hFile);
			}
			return bRet;
		}
	SeeAlso:
		FileTimeToSystemTime
*/
BOOL WINAPI SetFileTime(HANDLE hFile, const FILETIME *lpCreationTime, const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime);

/** >Date Time
	This function retrieves the current system date and time. The system time is expressed in Coordinated Universal Time (UTC). 
	Parameters:
		lpSystemTime = pointer to the SYSTEM struct to receive the date and time
	SeeAlso:
		SetFileTime, FileTimeToSystemTime, SystemTimeToJulianDate
*/
void WINAPI GetSystemTime(SYSTEMTIME* lpSystemTime);

    
/** >File Management
	The FileTimeToLocalFileTime function converts a file time to a local file time. 

	Remark:
		This function uses the current settings for the time zone and daylight saving time.
		Therefore, if it is daylight saving time, this function will take daylight saving time 
		into account, even if the time you are converting is in standard time. 

	Parameters:
		lpFileTime = pointer to file time to convert
		lpLocalFileTime = pointer to a FILETIME struct to receive the converted value
	Return:
		TRUE if success, FALSE if error
	Example:
		bool show_file_time(LPCSTR lpcsFilename)
		{
			WIN32_FILE_ATTRIBUTE_DATA	fileInfo;
		
			if(GetFileAttributesEx(lpcsFilename, 0, &fileInfo))
			{
				FILETIME localFiletime;
				if(FileTimeToLocalFileTime(&fileInfo.ftLastWriteTime, &localFiletime))
				{
					SYSTEMTIME sysTime;
					if(FileTimeToSystemTime(&localFiletime, &sysTime))
					{
						printf("%s is last modified at %.2d-%.2d-%4d %.2d:%.2d:%.2d\n",
						lpcsFilename,
						sysTime.wMonth,sysTime.wDay,sysTime.wYear,
						sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
						return TRUE;
					}
				}
			}
			return FALSE;
		}

*/
BOOL WINAPI FileTimeToLocalFileTime(
    const FILETIME *lpFileTime,	// file time to convert
    FILETIME* lpLocalFileTime	// receives system time
    );

/**# >File Management
*/
BOOL WINAPI LocalFileTimeToFileTime(
    const FILETIME *lpLocalFileTime,
    FILETIME* lpFileTime
    );

/** >File Management
		compares two 64-bit file times
	Parameters:
		lpFileTime1 = pointer to the first file time
		lpFileTime2 = pointer to the second file time
	Return:
			-1 First file time is less than second file time. 
			0 First file time is equal to second file time. 
			+1 First file time is greater than second file time.
	Example:
		// Note that the file c:\myfile.txt must exist for this example to run.
		void	run_CompareFileTime()
		{
			string						strFile = "c:\\myfile.txt";
			WIN32_FILE_ATTRIBUTE_DATA	fileInfo;
			// Get the attributes structure of the file
			if ( GetFileAttributesEx(strFile, 0, &fileInfo) )
			{
				int		nCompare = CompareFileTime(&fileInfo.ftLastAccessTime, &fileInfo.ftLastWriteTime);
				if (nCompare < 0)
					out_str("Last access time is less than last write time");
				else if (0 == nCompare)
					out_str("Last access time is the same as last write time");
				else
					out_str("Last access time is greater than last write time");
			}
			else
				out_str("Cannot get file attributes!");
		}
*/
LONG WINAPI CompareFileTime(
    const FILETIME *lpFileTime1,
    const FILETIME *lpFileTime2
    );

/**# >File Management
	converts a 64-bit file time to MS-DOS date and time values
	Parameters:
	lpFatDate = Pointer to a variable to receive the MS-DOS date.
		The date is a packed 16-bit value with the following bits Contents 
			0-4 Day of the month (1-31) 
			5-8 Month (1 = January, 2 = February, etc.) 
			9-15 Year offset from 1980 (add 1980 to get actual year) 
	lpFatTime = Pointer to a variable to receive the MS-DOS time.
		The time is a packed 16-bit value with the following bits Contents 
			0-4 Second divided by 2 
			5-10 Minute (0-59) 
			11-15 Hour (0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -