HANDLE hMutex=NULL; //全局变量
void RecordDllLog(string msgcontent) { WaitForSingleObject(hMutex,INFINITE); ofstream ofile; ofile.open("dlllog.txt",ios::app); //当前目录 if (!ofile) { return; } ofile <<msgcontent<<endl; ofile.close(); ReleaseMutex(hMutex); } int main() { hMutex=CreateMutex(NULL,FALSE,NULL); void RecordDllLog(string msgcontent); return 0; } |