Gn2DMeshObject* Gn2DMeshObject::Create(const gchar* pcFilePath, bool bUseGn2DMeshData) { gchar gmFullFilePath[GN_MAX_PATH] = { 0, }; GnStrcpy( gmFullFilePath, GnSystem::GetWorkDirectory(), sizeof(gmFullFilePath) ); GnStrcat( gmFullFilePath, pcFilePath, sizeof(gmFullFilePath) ); return CreateFullPath( gmFullFilePath, bUseGn2DMeshData ); }
/*>int main(int argc, char **argv) ------------------------------- Main program for submitting jobs to a farm 14.09.00 Original By: ACRM */ int main(int argc, char **argv) { uid_t uid; gid_t gid; char jobfile[PATH_MAX], *env; BOOL doDelete = FALSE, quiet = FALSE; int status, cluster = 0, nice = 10, port = 0; ULONG jobnum; char spoolDir[PATH_MAX], lockhost[MAXBUFF]; /* Get the default spool directory from the environment variable if this has been set */ if((env=getenv("QLSPOOLDIR"))!=NULL) strcpy(spoolDir, env); else strcpy(spoolDir, DEF_SPOOLDIR); /* Get the default cluster from the environment variable if this has been set */ if((env=getenv("QLCLUSTER"))!=NULL) sscanf(env,"%d", &cluster); if(ParseCmdLine(argc, argv, jobfile, &doDelete, spoolDir, &quiet, &cluster, &nice, lockhost, &port)) { CreateFullPath(jobfile); if(cluster!=0) UpdateSpoolDir(spoolDir, cluster); if(!CheckForSpoolDir(spoolDir)) { fprintf(stderr,"Spool directory, %s, does not exist!\n", spoolDir); return(1); } /* If either the port of host has not been specified get the values from a file */ if((port==0) || (!lockhost[0])) { GetPortAndLockHost(spoolDir, &port, lockhost); if(!lockhost[0]) { fprintf(stderr,"You must specify a host running the \ qllockd locking daemon\n"); fprintf(stderr," Either use the .qllockdaemon file in \ the spool directory or the -l flag\n"); return(1); }
// 打开图片 BOOL CMsPngImage::Open(TCHAR* szImageFileName) { BOOL bRet = CreateFullPath(m_szFullPath, szImageFileName); AssertEx(bRet, _T("路径解析错误")); // 打开图片文件 m_hFile = ::CreateFile( m_szFullPath, FILE_READ_DATA, 0, NULL, OPEN_EXISTING, 0, NULL ); AssertEx(m_hFile, _T("打开图片失败")); return TRUE; }
bool V4fWriter::Open() { if (Opened || CURRENT_POSITION().Value().direction <= 0) return false; try { SECURITY_ATTRIBUTES sa; sa.nLength= sizeof(sa); sa.lpSecurityDescriptor= NULL; time_t now = time(NULL); localtime(&now); char hms[32]=""; char full_path [MAX_PATH] = "", short_path [128] = ""; strftime(hms, 31, "%Hh%Mm%Ss", localtime(&now)); _snprintf(short_path, 127, "%s_%s.v4f", wstring_to_string(cameraName).c_str(), hms); CreateFullPath(full_path, CURRENT_POSITION().Value().direction, CURRENT_POSITION().Value().way, CURRENT_POSITION().Value().start_time, short_path, wstring_to_string(VIDEO_OPTIONS().Value().video_server)); fullPath = string_to_wstring(full_path); dataSet = new V4fDataSet(wstring_to_string(fullPath), short_path, CURRENT_POSITION().Value().direction, CURRENT_POSITION().Value().way, CURRENT_POSITION().Value().start_time); if(dataSet) { dataSet->OpenWriteFile(); dataSet->WriteHeader(); Opened = true; current_start_time = CURRENT_POSITION().Value().start_time; return true; } } catch(std::exception e) { LOG_ERROR(L"ќшибка при открытии файла .v4f"); } return false; }
/////////////////////////////////////////////////////////////////////////////// /// \brief /// Generate tile and lock pathnames. /// void MgdTileCache::GeneratePathnames(MgResourceIdentifier* mapDef, int scaleIndex, CREFSTRING group, int tileColumn, int tileRow, STRING& tilePathname, STRING& lockPathname, bool createFullPath) { STRING fileName = L"/" + GetTileName(tileRow, tileColumn) + L"."; STRING basePath = GetBasePath(mapDef); if (createFullPath) { tilePathname = CreateFullPath(basePath, scaleIndex, group, tileColumn, tileRow); } else { tilePathname = GetFullPath(basePath, scaleIndex, group, tileColumn, tileRow); } // Generate the tile and lock pathnames // <tilePathname> = <fullPath>/<row>_<column>.png/jpg // <lockPathname> = <fullPath>/<row>_<column>.lck tilePathname += fileName; lockPathname = tilePathname; if (MgdTileParameters::tileFormat == MgdImageFormats::Jpeg) { tilePathname += L"jpg"; } else if (MgdTileParameters::tileFormat == MgdImageFormats::Gif) { tilePathname += L"gif"; } else { tilePathname += L"png"; } lockPathname += L"lck"; }
CMsLog::CMsLog(LOG_FILE_INFO* pLogFileInfo, DWORD dwLogFileCount, BOOL bLock) : m_dwFileIndex (0) , m_bSaveLog (TRUE) , m_QuondamValueSaveLog (INVALID_NID) , m_bEnable (TRUE) , m_pLogFileInfo (NULL) , m_dwLogFileCount (dwLogFileCount) , m_bPause (FALSE) , m_bfIntensity (FALSE) , m_bLock (bLock) { //AUTO_LOCK(s_Loglock); if (!s_dwLogCount) { s_pCMsConsole = NEW CMsConsole(NULL); AssertEx(AL_CATAST, s_pCMsConsole, _T("内存不足")); } s_dwLogCount++; m_pLogFileInfo = NEW LOG_FILE_INFO[dwLogFileCount]; if (pLogFileInfo && m_dwLogFileCount && m_pLogFileInfo) { ZeroMemory(m_pLogFileInfo, sizeof(LOG_FILE_INFO) * dwLogFileCount); FOR_x_TO(i, dwLogFileCount) { if (pLogFileInfo->m_szLogFileName) { BOOL bRet = CreateFullPath(m_pLogFileInfo[i].m_szLogFileName, pLogFileInfo->m_szLogFileName); AssertEx(AL_NORMAL, bRet, _T("解析日志文件路径失败")); } else { AssertEx(AL_NORMAL, pLogFileInfo->m_szLogFileName, _T("日志路径不能为空")); } } }
STRING MgdTileCache::CreateFullPath(MgMapBase* map, int scaleIndex, CREFSTRING group, int tileColumn, int tileRow) { return CreateFullPath(GetBasePath(map), scaleIndex, group, tileColumn, tileRow); }
STRING MgdTileCache::CreateFullPath(MgResourceIdentifier* mapDef, int scaleIndex, CREFSTRING group, int tileColumn, int tileRow) { return CreateFullPath(GetBasePath(mapDef), scaleIndex, group, tileColumn, tileRow); }
void ParseArc(FILE *infile, bool quietMode) { ArchiveHeaderArc header = { 0 }; int archiveSize = 0; fseek(infile,0,SEEK_END); archiveSize = ftell(infile); rewind(infile); fread(header.magic, 1, 4, infile); fread(&header.table1Offset, 1, 4, infile); fread(&header.table2Offset, 1, 4, infile); fread(&header.table3Offset, 1, 4, infile); fread(&header.filenameTableOffset, 1, 4, infile); fread(&header.dataOffset, 1, 4, infile); ParseFilenames(infile, header); ParseFileEntries(infile, header); //ParseDirectoryEntries(infile, header); // Create all of the possible directory paths in one go instead of trying to create // each full path during the file dumping loop for(int i = 0; i < foldernames.size(); i++) { CreateFullPath(foldernames[i]); } std::string currentFolder = ""; int dumped = 0; char *buffer = NULL; int bufferSize = 0; for(int i = 0; i < filenames.size(); i++) { if(filenames[i][filenames[i].size() - 1] == '/') { currentFolder = filenames[i]; } else { std::string fullpath = currentFolder + filenames[i]; unsigned int crc32 = CalculateCrc32((char*)filenames[i].c_str(), filenames[i].size()); if(file_index.find(crc32) != file_index.end()) { int idx = file_index[crc32]; if(!quietMode) { printf("[%06d] %-38s size[%08x] offset[%08x]\n", dumped, fullpath.c_str(), file_entries[idx].filesize, file_entries[idx].offset); } dumped++; if(file_entries[idx].filesize > bufferSize) { bufferSize = file_entries[idx].filesize * 2; if(buffer == NULL) { buffer = (char*)calloc(bufferSize, sizeof(char)); } else { buffer = (char*)realloc(buffer, bufferSize); } } if(header.dataOffset + file_entries[idx].offset > archiveSize) { //printf("Couldn't seek passed end of file\n"); continue; } fseek(infile,header.dataOffset + file_entries[idx].offset,SEEK_SET); fread(buffer, 1, file_entries[idx].filesize, infile); FILE *outfile = fopen(fullpath.c_str(), "wb"); if(!outfile) { printf("Could not open %s\n", fullpath.c_str()); exit(-1); } fwrite(buffer, 1, file_entries[idx].filesize, outfile); fclose(outfile); } else { printf("Could not find crc32 %08x: %s\n",crc32, filenames[i].c_str()); exit(1); } } } if(buffer != NULL) free(buffer); }
void ParseXpck(FILE *infile, bool quietMode) { ArchiveHeaderXpck header = { 0 }; int archiveSize = 0; fseek(infile,0,SEEK_END); archiveSize = ftell(infile); rewind(infile); fread(header.magic, 1, 4, infile); fread(&header.fileCount, 1, 1, infile); fread(&header.unknown, 1, 1, infile); fread(&header.fileInfoOffset, 1, 2, infile); fread(&header.filenameTableOffset, 1, 2, infile); fread(&header.dataOffset, 1, 2, infile); fread(&header.fileInfoSize, 1, 2, infile); fread(&header.filenameTableSize, 1, 2, infile); fread(&header.dataSize, 1, 4, infile); header.fileInfoOffset *= 4; header.filenameTableOffset *= 4; header.dataOffset *= 4; header.fileInfoSize *= 4; header.filenameTableSize *= 4; header.dataSize *= 4; ParseFilenames(infile, header); ParseFileEntries(infile, header); // Create all of the possible directory paths in one go instead of trying to create // each full path during the file dumping loop for(int i = 0; i < foldernames.size(); i++) { CreateFullPath(foldernames[i]); } std::string currentFolder = ""; int dumped = 0; char *buffer = NULL; int bufferSize = 0; for(int i = 0; i < filenames.size(); i++) { if(filenames[i][filenames[i].size() - 1] == '/') { currentFolder = filenames[i]; } else { std::string fullpath = currentFolder + filenames[i]; unsigned int crc32 = CalculateCrc32((char*)filenames[i].c_str(), filenames[i].size()); if(file_index.find(crc32) != file_index.end()) { int idx = file_index[crc32]; if(file_entries[idx].filesize > bufferSize) { bufferSize = file_entries[idx].filesize * 2; if(buffer == NULL) { buffer = (char*)calloc(bufferSize, sizeof(char)); } else { buffer = (char*)realloc(buffer, bufferSize); } } if(header.dataOffset + file_entries[idx].offset > archiveSize) { //printf("Couldn't seek passed end of file\n"); continue; } fseek(infile,header.dataOffset + file_entries[idx].offset,SEEK_SET); fread(buffer, 1, file_entries[idx].filesize, infile); // Try to decompress data if(memcmp(buffer + 4, "\0DVLB", 5) == 0 || memcmp(buffer + 4, "\0XPCK", 5) == 0 || memcmp(buffer + 4, "\0CHRC", 5) == 0 || memcmp(buffer + 4, "\0RESC", 5) == 0) { int length = *(int*)buffer; length /= 8; int output_len = 0; char *data = decompress(buffer, file_entries[idx].filesize, &output_len); // Replace the running buffer with the decompressed data's buffer. // Lazy way to handle this without changign the code after. free(buffer); buffer = data; file_entries[idx].filesize = output_len; bufferSize = output_len; } if(!quietMode) { printf("[%06d] %-38s size[%08x] offset[%08x]\n", dumped, fullpath.c_str(), file_entries[idx].filesize, file_entries[idx].offset); } dumped++; FILE *outfile = fopen(fullpath.c_str(), "wb"); if(!outfile) { printf("Could not open %s\n", fullpath.c_str()); exit(-1); } fwrite(buffer, 1, file_entries[idx].filesize, outfile); fclose(outfile); } else { printf("Could not find crc32 %08x: %s\n",crc32, filenames[i].c_str()); exit(1); } } } if(buffer != NULL) free(buffer); }
//*********************************************************************************************** // Saves an FTL File // Must pass the original name of the theo file //----------------------------------------------------------------------------------------------- // VERIFIED (Cyril 2001/10/15) //*********************************************************************************************** bool ARX_FTL_Save(const char * file, EERIE_3DOBJ * obj) { // Need an object to be saved ! if (obj == NULL) return false; // Generate File name/path and create it char path[256]; char gamefic[256]; sprintf(gamefic, "Game\\%s", file); SetExt(gamefic, ".FTL"); strcpy(path, gamefic); RemoveName(path); if (!CreateFullPath(path)) return NULL; // create some usefull vars ARX_FTL_PRIMARY_HEADER * afph; ARX_FTL_SECONDARY_HEADER * afsh; ARX_FTL_CLOTHES_DATA_HEADER * afcdh; ARX_FTL_3D_DATA_HEADER * af3Ddh; ARX_FTL_COLLISION_SPHERES_DATA_HEADER * afcsdh; unsigned char * dat = NULL; long pos = 0; long allocsize = 8000000; // need to compute it more precisely // Compute allocsize... allocsize = sizeof(ARX_FTL_PRIMARY_HEADER) + 512 //checksum + sizeof(ARX_FTL_SECONDARY_HEADER) + sizeof(ARX_FTL_3D_DATA_HEADER) + sizeof(EERIE_OLD_VERTEX) * obj->nbvertex + sizeof(EERIE_FACE_FTL) * obj->nbfaces + obj->nbmaps * 256 // texturecontainernames + sizeof(EERIE_ACTIONLIST) * obj->nbaction + 128000; // just in case... if (obj->nbgroups > 0) { allocsize += sizeof(EERIE_GROUPLIST) * obj->nbgroups; for (long i = 0; i < obj->nbgroups; i++) { if (obj->grouplist[i].nb_index > 0) { allocsize += sizeof(long) * obj->grouplist[i].nb_index; } } } if (obj->nbselections > 0) { allocsize += sizeof(EERIE_SELECTIONS) * obj->nbselections; for (long i = 0; i < obj->nbselections; i++) { allocsize += sizeof(long) * obj->selections[i].nb_selected; } } if (obj->sdata && obj->sdata->nb_spheres) // Collision Spheres Data { allocsize += sizeof(ARX_FTL_COLLISION_SPHERES_DATA_HEADER); allocsize += sizeof(COLLISION_SPHERE) * obj->sdata->nb_spheres; } if (obj->cdata) // Clothes DATA { allocsize += sizeof(ARX_FTL_CLOTHES_DATA_HEADER); allocsize += sizeof(CLOTHESVERTEX) * obj->cdata->nb_cvert; allocsize += sizeof(EERIE_SPRINGS) * obj->cdata->nb_springs; } // Finished computing allocsize Now allocate it... dat = (unsigned char *)malloc(allocsize); if (!dat) HERMES_Memory_Emergency_Out(); memset(dat, 0, allocsize); // Primary Header afph = (ARX_FTL_PRIMARY_HEADER *)dat; pos += sizeof(ARX_FTL_PRIMARY_HEADER); if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); afph->ident[0] = 'F'; afph->ident[1] = 'T'; afph->ident[2] = 'L'; afph->version = CURRENT_FTL_VERSION; // Identification char check[512]; HERMES_CreateFileCheck(file, check, 512, CURRENT_FTL_VERSION); memcpy(dat + pos, check, 512); pos += 512; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); // Secondary Header afsh = (ARX_FTL_SECONDARY_HEADER *)(dat + pos); pos += sizeof(ARX_FTL_SECONDARY_HEADER); if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); // 3D Data afsh->offset_3Ddata = pos; //-1; af3Ddh = (ARX_FTL_3D_DATA_HEADER *)(dat + afsh->offset_3Ddata); pos += sizeof(ARX_FTL_3D_DATA_HEADER); if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); af3Ddh->nb_vertex = obj->nbvertex; af3Ddh->nb_faces = obj->nbfaces; af3Ddh->nb_maps = obj->nbmaps; af3Ddh->nb_groups = obj->nbgroups; af3Ddh->nb_action = obj->nbaction; af3Ddh->nb_selections = obj->nbselections; af3Ddh->origin = obj->origin; // vertexes if (af3Ddh->nb_vertex > 0) { for (long ii = 0; ii < af3Ddh->nb_vertex; ii++) { memcpy(dat + pos, &obj->vertexlist[ii], sizeof(EERIE_OLD_VERTEX)); pos += sizeof(EERIE_OLD_VERTEX); } if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); } // faces if (af3Ddh->nb_faces > 0) { for (long ii = 0; ii < af3Ddh->nb_faces; ii++) { EERIE_FACE_FTL * eff = (EERIE_FACE_FTL *)(dat + pos); eff->facetype = obj->facelist[ii].facetype; eff->texid = obj->facelist[ii].texid; eff->transval = obj->facelist[ii].transval; eff->temp = obj->facelist[ii].temp; memcpy(&eff->norm, &obj->facelist[ii].norm, sizeof(EERIE_3D)); for (long kk = 0; kk < IOPOLYVERT; kk++) { memcpy(&eff->nrmls[kk], &obj->facelist[ii].nrmls[kk], sizeof(EERIE_3D)); eff->vid[kk] = obj->facelist[ii].vid[kk]; eff->u[kk] = obj->facelist[ii].u[kk]; eff->v[kk] = obj->facelist[ii].v[kk]; eff->ou[kk] = obj->facelist[ii].ou[kk]; eff->ov[kk] = obj->facelist[ii].ov[kk]; eff->rgb[kk] = 0; } pos += sizeof(EERIE_FACE_FTL); if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); } } // textures for (long i = 0; i < af3Ddh->nb_maps; i++) { char ficc[256]; memset(ficc, 0, 256); if (obj->texturecontainer[i]) strcpy(ficc, obj->texturecontainer[i]->m_texName); memcpy(dat + pos, ficc, 256); pos += 256; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); } // groups if (af3Ddh->nb_groups > 0) { memcpy(dat + pos, obj->grouplist, sizeof(EERIE_GROUPLIST)*af3Ddh->nb_groups); pos += sizeof(EERIE_GROUPLIST) * af3Ddh->nb_groups; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); for (int i = 0; i < af3Ddh->nb_groups; i++) { if (obj->grouplist[i].nb_index > 0) { memcpy(dat + pos, obj->grouplist[i].indexes, sizeof(long)*obj->grouplist[i].nb_index); pos += sizeof(long) * obj->grouplist[i].nb_index; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); } } } // actionpoints if (af3Ddh->nb_action > 0) { memcpy(dat + pos, obj->actionlist, sizeof(EERIE_ACTIONLIST)*af3Ddh->nb_action); pos += sizeof(EERIE_ACTIONLIST) * af3Ddh->nb_action; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); } // selections if (af3Ddh->nb_selections > 0) { memcpy(dat + pos, obj->selections, sizeof(EERIE_SELECTIONS)*af3Ddh->nb_selections); pos += sizeof(EERIE_SELECTIONS) * af3Ddh->nb_selections; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); for (int i = 0; i < af3Ddh->nb_selections; i++) { memcpy(dat + pos, obj->selections[i].selected, sizeof(long)*obj->selections[i].nb_selected); pos += sizeof(long) * obj->selections[i].nb_selected; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); } strcpy(af3Ddh->name, obj->file); } // Progressive DATA afsh->offset_progressive_data = -1; // Collision Spheres Data if (obj->sdata && obj->sdata->nb_spheres) { afsh->offset_collision_spheres = pos; //-1; afcsdh = (ARX_FTL_COLLISION_SPHERES_DATA_HEADER *)(dat + afsh->offset_collision_spheres); pos += sizeof(ARX_FTL_COLLISION_SPHERES_DATA_HEADER); if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); afcsdh->nb_spheres = obj->sdata->nb_spheres; memcpy(dat + pos, obj->sdata->spheres, sizeof(COLLISION_SPHERE)*obj->sdata->nb_spheres); pos += sizeof(COLLISION_SPHERE) * obj->sdata->nb_spheres; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); } else afsh->offset_collision_spheres = -1; // Clothes DATA if (obj->cdata == NULL) { afsh->offset_clothes_data = -1; } else { afsh->offset_clothes_data = pos; afcdh = (ARX_FTL_CLOTHES_DATA_HEADER *)(dat + afsh->offset_clothes_data); afcdh->nb_cvert = obj->cdata->nb_cvert; afcdh->nb_springs = obj->cdata->nb_springs; pos += sizeof(ARX_FTL_CLOTHES_DATA_HEADER); if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); // now save cvert memcpy(dat + pos, obj->cdata->cvert, sizeof(CLOTHESVERTEX)*obj->cdata->nb_cvert); pos += sizeof(CLOTHESVERTEX) * obj->cdata->nb_cvert; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); // now saves springs memcpy(dat + pos, obj->cdata->springs, sizeof(EERIE_SPRINGS)*obj->cdata->nb_springs); pos += sizeof(EERIE_SPRINGS) * obj->cdata->nb_springs; if (pos > allocsize) ShowPopup("Invalid Allocsize in ARX_FTL_Save"); } afsh->offset_physics_box = -1; afsh->offset_cylinder = -1; // Now we can flush our cool FTL file to the hard drive FileHandle handle; char _error[512]; if (pos > allocsize) { sprintf(_error, "Badly Allocated SaveBuffer...%s", gamefic); goto error; } char * compressed; compressed = NULL; long cpr_pos; cpr_pos = 0; LogError <<"IMPLODE NOT IMPLEMENTED"; // TODO fix //compressed = STD_Implode((char *)dat, pos, &cpr_pos); // Now Saving Whole Buffer if (!(handle = FileOpenWrite(gamefic))) { sprintf(_error, "Unable to Open %s for Write...", gamefic); goto error; } if (FileWrite(handle, compressed, cpr_pos) != cpr_pos) { sprintf(_error, "Unable to Write to %s", gamefic); goto error; } FileCloseWrite(handle); free(compressed); free(dat); return true; error: ; ShowPopup(_error); free(dat); return false; }
INT_PTR CALLBACK DlgProc( _In_ HWND hDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { int wmId, wmEvent; static ChromeInfo chromeInfo; static TCHAR ltcChromeDetected[MAX_LOADSTRING]; static TCHAR ltcChromeNotDetected[MAX_LOADSTRING]; static TCHAR ltcSendSuccess[MAX_LOADSTRING]; static TCHAR ltcSendFailed[MAX_LOADSTRING]; static char szVariable[MAX_LOADSTRING]; static char sRawFilepath[MAX_PATH]; static char sUrl[MAX_PATH]; static tstringstream os; switch (uMsg) { case WM_INITDIALOG: { HINSTANCE hInstance = reinterpret_cast<HINSTANCE>(lParam); TCHAR szTemp[MAX_LOADSTRING]; if (0 != LoadString(hInstance, IDS_APP_TITLE, szTemp, MAX_LOADSTRING)){ SetWindowText(hDlg, szTemp); } if (0 != LoadString(hInstance, IDS_BTN_SEND_CAPTION, szTemp, MAX_LOADSTRING)){ SetDlgItemText(hDlg, IDC_BTN_SEND, szTemp); } LoadStringOrDefault(hInstance, ltcChromeDetected, MAX_LOADSTRING, IDS_CHROME_DETECTED, g_tcChromeDetected); LoadStringOrDefault(hInstance, ltcChromeNotDetected, MAX_LOADSTRING, IDS_CHROME_NOTDETECTED, g_tcChromeNotDetected); SetDlgItemText(hDlg, IDC_LBL_CHROME_STATUS, ltcChromeNotDetected); LoadStringOrDefault(hInstance, ltcSendFailed, MAX_LOADSTRING, IDS_SEND_FAILED, g_tcSendFailed); LoadStringOrDefault(hInstance, ltcSendSuccess, MAX_LOADSTRING, IDS_SEND_SUCCESS, g_tcSendSuccess); SetDlgItemText(hDlg, IDC_LBL_SEND_STATUS, TEXT("")); if (0 != SetTimer(hDlg, IDT_REFRESH_CHROME_STATUS, int(1000 / refreshratehz), NULL)) { ShowWindow(GetDlgItem(hDlg, IDC_BTN_REFRESH), SW_HIDE); } else { if (0 != LoadString(hInstance, IDS_BTN_REFRESH_CAPTION, szTemp, MAX_LOADSTRING)){ SetDlgItemText(hDlg, IDC_BTN_REFRESH, szTemp); } ShowWindow(GetDlgItem(hDlg, IDC_BTN_REFRESH), SW_SHOW); } char* pTemp = 0; if (AllocAndCopyTCtoMB(&pTemp, g_tcRawFilepath, MAX_PATH)) { StringCbCopyA(sRawFilepath, MAX_PATH, pTemp); delete[] pTemp; } pTemp = 0; if (AllocAndCopyTCtoMB(&pTemp, g_tcUrl, MAX_PATH)) { StringCbCopyA(sUrl, MAX_PATH, pTemp); delete[] pTemp; } StringCbCopyA(szVariable, MAX_LOADSTRING, "filearg"); UpdateField(hDlg, IDC_EDT_FILEPATH, sRawFilepath, MAX_PATH, true); UpdateField(hDlg, IDC_EDT_SEND_URL, sUrl, MAX_PATH, true); } return TRUE; case WM_TIMER: switch (wParam) { case IDT_REFRESH_CHROME_STATUS: if(DetectChrome(&chromeInfo, g_tcImageName)){ os.str(TEXT("")); os.clear(); os<<ltcChromeDetected<<" (pid: "<<chromeInfo.dwProcId<<")"<<std::endl; SetDlgItemText(hDlg, IDC_LBL_CHROME_STATUS, os.str().c_str()); } else { SetDlgItemText(hDlg, IDC_LBL_CHROME_STATUS, ltcChromeNotDetected); } return TRUE; } break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case IDCANCEL: SendMessage(hDlg, WM_CLOSE, 0, 0); return TRUE; case IDC_BTN_SEND:{ UpdateField(hDlg, IDC_EDT_FILEPATH, sRawFilepath, MAX_PATH); UpdateField(hDlg, IDC_EDT_SEND_URL, sUrl, MAX_PATH); TCHAR tcRawFilepath[MAX_PATH]; TCHAR tcUrl[MAX_PATH]; TCHAR* pTemp = 0; if (AllocAndCopyMBtoTC(&pTemp, sUrl, MAX_PATH)) { StringCbCopy(tcUrl, MAX_PATH, pTemp); delete[] pTemp; } pTemp = 0; if (AllocAndCopyMBtoTC(&pTemp, sRawFilepath, MAX_PATH)) { StringCbCopy(tcRawFilepath, MAX_PATH, pTemp); delete[] pTemp; } TCHAR tcFullPath[MAX_PATH]; TCHAR *tcFilenamePart; if(CreateFullPath(tcRawFilepath, tcFullPath, sizeof(tcFullPath)/ sizeof(TCHAR), &tcFilenamePart) ) { char* pFilenamePart = 0; if (AllocAndCopyTCtoMB(&pFilenamePart, tcFilenamePart, MAX_PATH)) if(SendFile(GetFile(tcFullPath), tcUrl, szVariable, pFilenamePart)) { SetDlgItemText(hDlg, IDC_LBL_SEND_STATUS, ltcSendSuccess); } else { SetDlgItemText(hDlg, IDC_LBL_SEND_STATUS, ltcSendFailed); } if(pFilenamePart) delete[] pFilenamePart; } } return TRUE; case IDC_BTN_REFRESH: if(DetectChrome(&chromeInfo, g_tcImageName, true)){ SetDlgItemText(hDlg, IDC_LBL_CHROME_STATUS, ltcChromeDetected); } else { SetDlgItemText(hDlg, IDC_LBL_CHROME_STATUS, ltcChromeNotDetected); } return TRUE; } break; case WM_CLOSE: KillTimer(hDlg, IDT_REFRESH_CHROME_STATUS); DestroyWindow(hDlg); return TRUE; case WM_DESTROY: PostQuitMessage(0); return TRUE; } return FALSE; }