1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
int CreateSeparator(char depth[50],char* prefixString,char* suffixString,HWND hwnd)
{
FILE *f;
int i=0,depthLength=0,depthBufferLength=0,lengthDiff=0;
char buffer[100],depth2[20],commandString1[50],commandString2[50],commandString3[50];
char key[20] = "\"";
//Recording length of depth number
depthLength=strlen(depth);
strcpy(commandString1,"/c copy \"C:\\WINDOWS\\Separator_Model.txt\" \"");
strcpy(commandString2,"Separator_");
strcpy(commandString3,".txt\"\0");
strcat(commandString1,commandString2);
strncat(commandString1,depth,depthLength);
strcat(commandString1,".txt\"");
strncat(commandString2,depth,depthLength);
strcat(commandString2,".txt");
//Execute copy command
//system(commandString1);
//C++ Way
SHELLEXECUTEINFO ExecuteCopyInfo;
memset(&ExecuteCopyInfo, 0, sizeof(ExecuteCopyInfo));
ExecuteCopyInfo.cbSize = sizeof(ExecuteCopyInfo);
ExecuteCopyInfo.fMask = 0;
ExecuteCopyInfo.hwnd = 0;
ExecuteCopyInfo.lpVerb = "open";
ExecuteCopyInfo.lpFile = "c:\\windows\\system32\\cmd.exe";
ExecuteCopyInfo.lpParameters = commandString1;
ExecuteCopyInfo.lpDirectory = 0;
ExecuteCopyInfo.nShow = SW_HIDE;
ExecuteCopyInfo.hInstApp = 0;
if(ShellExecuteEx(&ExecuteCopyInfo) == FALSE)
{
// erreur
}
else
{
MessageBox(hwnd,commandString2,"Comandstring",MB_OK);
WaitForSingleObject(ExecuteCopyInfo.hProcess, INFINITE);
}
::CloseHandle(ExecuteCopyInfo.hProcess);
// MessageBox(hwnd,commandString2,"Comandstring",MB_OK);
f = fopen( commandString2 , "r+" );
// MessageBox(hwnd,commandString2,"Comandstring",MB_OK);
while(strcmp(buffer,key)!=0 )
{
fscanf(f,"%s",buffer);
}
//MessageBox(hwnd,"ok","ok",MB_OK);
//Prepare ASCII file
fseek (f,0,SEEK_CUR);
fputs (" ",f);
fputs (prefixString,f);
fputs (" ",f);
fputs (depth,f);
fputs (suffixString,f);
fputs (" \"",f);
fclose(f);
//Encode ASCII to PDS
strcpy(commandString1,"/c pdsencode -d \"Separator_");
strcpy(commandString2,".txt\" -p \"Separator_");
strcpy(commandString3,".pds\"");
strcpy(depth2,depth);
strcat(commandString1,depth);
strcat(commandString1,commandString2);
strcat(commandString1,depth);
strcat(commandString1,commandString3);
//MessageBox(hwnd,commandString1,"PDS encode Command",MB_OK);
//i = system (commandString1);
SHELLEXECUTEINFO ExecuteEncodeInfo;
memset(&ExecuteEncodeInfo, 0, sizeof(ExecuteEncodeInfo));
ExecuteEncodeInfo.cbSize = sizeof(ExecuteEncodeInfo);
ExecuteEncodeInfo.fMask = 0;
ExecuteEncodeInfo.hwnd = 0;
ExecuteEncodeInfo.lpVerb = "open";
ExecuteEncodeInfo.lpFile = "c:\\windows\\system32\\cmd.exe";
ExecuteEncodeInfo.lpParameters = commandString1;
ExecuteEncodeInfo.lpDirectory = 0;
ExecuteEncodeInfo.nShow = SW_HIDE;
ExecuteEncodeInfo.hInstApp = 0;
if(ShellExecuteEx(&ExecuteEncodeInfo) == FALSE)
{
// erreur
}
else
{
WaitForSingleObject(ExecuteEncodeInfo.hProcess, INFINITE);
}
::CloseHandle(ExecuteEncodeInfo.hProcess);
//Delete ASCII File
strcpy(commandString1,"/c del \"Separator_");
strcpy(commandString2,".txt");
strcat(commandString1,depth);
strcat(commandString1,commandString2);
//i = system (commandString1);
//MessageBox(hwnd,commandString1,"PDS encode Command",MB_OK);
SHELLEXECUTEINFO ExecuteDeleteInfo;
memset(&ExecuteDeleteInfo, 0, sizeof(ExecuteDeleteInfo));
ExecuteDeleteInfo.cbSize = sizeof(ExecuteDeleteInfo);
ExecuteDeleteInfo.fMask = 0;
ExecuteDeleteInfo.hwnd = 0;
ExecuteDeleteInfo.lpVerb = "open";
ExecuteDeleteInfo.lpFile = "c:\\windows\\system32\\cmd.exe";
ExecuteDeleteInfo.lpParameters = commandString1;
ExecuteDeleteInfo.lpDirectory = 0;
ExecuteDeleteInfo.nShow = SW_HIDE;
ExecuteDeleteInfo.hInstApp = 0;
if(ShellExecuteEx(&ExecuteDeleteInfo) == FALSE)
{
// erreur
}
else
{
WaitForSingleObject(ExecuteDeleteInfo.hProcess, INFINITE);
}
::CloseHandle(ExecuteDeleteInfo.hProcess);*/
return 0;
} |
Partager