VC++ 6.0 simple demo to dosomthing on the day

with timer~~~

/*

by c4rp3nt3r@gmail.com

http://c4rp3nt3r.blogspot.com

*/

int main(int argc, char* argv[])
{
   char szFormatDt[6];
   char szBirthDay[6];
   szBirthDay[0]='0';
   szBirthDay[1]='3';
   szBirthDay[2]='-';
   szBirthDay[3]='0';
   szBirthDay[4]='4';
   szBirthDay[5]='\0';

        int length = GetDateFormat (LOCALE_USER_DEFAULT,
          0,                   // Flags
          NULL,
          "MM-dd",                // Format
          szFormatDt,
          sizeof(szFormatDt)) ;

       if(strcmp(szBirthDay,szFormatDt)==0)
    {
   HANDLE hFile;
   hFile = CreateFile
    (
    "forfun.txt", 
    GENERIC_WRITE, 
    FILE_SHARE_WRITE, 
    NULL, 
    CREATE_ALWAYS,
    FILE_ATTRIBUTE_NORMAL, 
    NULL
    );
   if (hFile == NULL)
    return FALSE;
   char szInfo[] ="Just For Fun !"
"By 
c4rp3nt3r@gmail.com\r\n";
   DWORD dwBytes;
   WriteFile(hFile, szInfo, sizeof(szInfo), &dwBytes, NULL);
   CloseHandle(hFile);
   WinExec("notepad.exe forfun.txt",1);
   Sleep(1000);
   DeleteFile("forfun.txt");
  
    }
return 0;
}

0 评论: