//cpp for 3dGS plug_in
#include <string.h>
#include <stdio.h>
#include <windows.h>
void writeFile(const char* path,const char* str){
FILE *stream;
if((stream=fopen(path,"w+b"))!=NULL){
fwrite(str,sizeof(char), strlen(str), stream );
fclose(stream);
}else{
printf("fail:writeFile(...)");
}
}
char sBuf[128];
DWORD WINAPI ThreadFunc( LPVOID lpParam){
int i=0;
while(1){
i++;
char buffer[200];
memset(buffer,'\0',200);
sprintf(buffer,"C:\\save\\file_%d.txt",i);
//do something...
writeFile(buffer,buffer);
Sleep(1000);
}
return 0;
}
DLLFUNC void DllThread(){
DWORD dwThreadId, dwThrdParam = 1;
HANDLE hThread;
hThread = CreateThread(
NULL, // no security attributes
0, // use default stack size
ThreadFunc, // thread function
&dwThrdParam, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
if (hThread == NULL)
{
}
else
{
getchar();
writeFile("C:\\save\\finish.txt","0");
CloseHandle( hThread );
}
}