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

📄 文件操作.txt

📁 我自己写的一个通讯录 配合sql server 2000使用
💻 TXT
字号:
void CFatDlg::OnButton1() 
{
	//300b
 struct member
 {
   CString name;
   CString mbp;
   CString tel;
   CString addr1;
   CString qq;
   CString email;
   CString birth;
   CString id;
   CString beiyong;
   CString others;
 };
 struct member elem;
 elem.name+="你好。我是徐士斌";
 SetDlgItemText(IDC_EDIT1,elem.name);
}

void CFatDlg::OnButton2() 
{
 HANDLE hFile; // the file handle 
 DWORD dwFileSize; // temporary storage for file sizes 
 CString str="这个文件大小:";
 unsigned long lwtetteen;
 // Create the test file. Open it "Create Always" to overwrite any 
 // existing file. The data is re-created below. 
 hFile = CreateFile("c:\\bing.txt", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, 
 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 

 if (hFile==INVALID_HANDLE_VALUE) 
 { 
 SetDlgItemText(IDC_EDIT1,"hFile is NULL");
 return; 
 }
 SetFilePointer(hFile,0,0,FILE_BEGIN);
 WriteFile(hFile,str,strlen(str),&lwtetteen,NULL);
 dwFileSize=GetFileSize(hFile, NULL); 
 str.Format("%d",dwFileSize);
 str+="(测试)";
 SetDlgItemText(IDC_EDIT1,str);
}

void CFatDlg::OnOK() 
{
 HANDLE hFile; // the file handle 
 DWORD dwFileSize; // temporary storage for file sizes 
 char str[10];
 unsigned long lwtetteen;

 // Create the test file. Open it "Create Always" to overwrite any 
 // existing file. The data is re-created below. 
 hFile = CreateFile("c:\\bing.txt", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, 
 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 

 if (hFile==INVALID_HANDLE_VALUE) 
	{ 
	 SetDlgItemText(IDC_EDIT1,"hFile is NULL文件打不开");
  	 return; 
	}
 SetFilePointer(hFile,0,0,FILE_BEGIN);
 ReadFile(hFile,str,10,&lwtetteen,NULL);
//dwFileSize=GetFileSize(hFile, NULL); 
 //str.Format("%d",dwFileSize);
 //str+="(测试)";
 SetDlgItemText(IDC_EDIT1,str);
}
























struct member
 {
   CString name[15];
   CString mbp[23];
   CString tel[23];
   CString addr1[63];
   CString qq[15];
   CString email[19];
   CString birth[35];
   CString id[17];
   CString beiyong[19];
   CString others[67];
 };

⌨️ 快捷键说明

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