EvoTalk

14 二月, 2006

How to Access Text File in Resources?

Posted by: asd In: C++| Code Snippet| 程式設計 ()

C++:
  1. HRSRC h1 = FindResource(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_DT),"txt");
  2. HANDLE hTextResource = LoadResource(AfxGetResourceHandle(),h1);
  3. LPSTR lpResData = (LPSTR)::LockResource( hTextResource );
  4. if( !hTextResource )  {
  5.    AfxMessageBox("載入txt 失敗");
  6.    return;
  7. }   
  8. FILE *fmlist = fopen("lexdt.txt","w");
  9. fprintf(fmlist,"%s",lpResData);
  10. fclose(fmlist);
  11. FreeResource( hTextResource );

Most Commented Posts



No Responses to "How to Access Text File in Resources?"

Comment Form