Esempio n. 1
0
/////////////////////////////////////////////////////////////////////////////
// GetTempPath
// n.b. Overloads DWORD GetTempPath(DWORD nBufferLength, LPTSTR lpBuffer)
// There is a conversion from LPTSTR to CString
// TODO: Rename; this is needlessly dangerous
// TODO GetTempFolder does not contain the temp folder but returns the udf target folder. Hence the function name is not correct..!
/////////////////////////////////////////////////////////////////////////////
CString GetTempFolder(int iAccess, const CString strFolder)
{
	if (iAccess == USE_USER_SPECIFIED_DIR) {
		CString tempdir = strFolder;

		//Verify the chosen temp path is valid
		WIN32_FIND_DATA wfd;
		::ZeroMemory(&wfd, sizeof (wfd));
		HANDLE hdir = ::FindFirstFile(LPCTSTR(tempdir), &wfd);
		if (!hdir) {
			return GetProgPath();
		}
		::FindClose(hdir);

		//If valid directory, return Windows\temp as temp directory
		if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
			return tempdir;
		}
   }

   char tempPath[_MAX_PATH+1] = { '\0' };
   if (GetTempPath(_MAX_PATH, tempPath))
      {
	   CString tempdir;
      tempdir = tempPath;
      if (0 < tempdir.ReverseFind('\\'))
	      tempdir = tempdir.Left(tempdir.ReverseFind('\\'));
      return tempdir;
      }

   //This code looks for an old style temp directory. NOT standard windows.
	TCHAR dirx[_MAX_PATH];
	::GetWindowsDirectory(dirx, _MAX_PATH);
	CString tempdir;
	tempdir.Format(_T("%s\\temp"), dirx);

	// Verify the chosen temp path is valid

	WIN32_FIND_DATA wfd;
	::ZeroMemory(&wfd, sizeof (wfd));
	HANDLE hdir = ::FindFirstFile(LPCTSTR(tempdir), &wfd);
	if (!hdir) {
		return GetProgPath();
	}
	::FindClose(hdir);

	// If valid directory, return Windows\temp as temp directory
	if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
		return tempdir;
	}

	//else return program path as temp directory
	//iAccess = USE_INSTALLED_DIR;	// TODO: nonsense; iAccess is NOT an output
	return GetProgPath();
	
}
Esempio n. 2
0
void LogFileWrite( LPCSTR logstr )
{
	char ProgPath[256], LogFileName[256];
	memset( ProgPath, 0x00, 256 );
	memset( LogFileName, 0x00, 256 );
	CFile file;
	int loglength;

	GetProgPath(ProgPath);
	loglength = strlen( logstr );

	sprintf( LogFileName, "%s\\Aujard.log", ProgPath);
	
	file.Open( LogFileName, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite );

	file.SeekToEnd();
	file.Write(logstr, loglength);
	file.Close();
}
Esempio n. 3
0
void CAudioFormatDlg::OnHelp()
{
	CString progdir = GetProgPath();
	CString helppath = progdir + _T("\\help.htm#Helpmci");
	Openlink(helppath);
}
Esempio n. 4
0
BOOL CSampleApp::InitInstance()
{
	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

	// initialized OLE 2.0 libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDS_OLE_INIT_FAILED);
		return FALSE;
	}

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("RenderSoft TextCalc"));

	LoadStdProfileSettings(10);  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_SAMPLETYPE,
		RUNTIME_CLASS(CSampleDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CSampleView));
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Enable DDE Execute open
//	EnableShellOpen();
//	RegisterShellFileTypes(TRUE);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	/*
	//if (cmdInfo!=NULL) 
		if (cmdInfo.m_strFileName!=NULL) 
			if (cmdInfo.m_strFileName!="") 
			*/

	if (cmdInfo.m_nShellCommand==CCommandLineInfo::FileOpen)
			m_nCmdShow=SW_SHOWMAXIMIZED;

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(m_nCmdShow);
	//pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
	pMainFrame->UpdateWindow();


	if (IsFirstLoad()) {

		int rt=MessageBox(NULL,"This is the first time you are running TextCalc.\n\nDo you want to load the help file?", "Invoke Help?", MB_YESNO | MB_ICONQUESTION);
		
		CString px=GetProgPath();
		CString filex=px+"\\"+"progdata.nfo";
		
		FILE *fp;
		fp=fopen(filex,"w");
		if (fp!=NULL)  {
			fprintf(fp,"<Not first load> = true");
			if (fp!=NULL) fclose(fp);
		}

		if (rt==IDNO) return TRUE;

		POSITION x=GetFirstDocTemplatePosition( );
		if (x==NULL) return TRUE;
		
		CDocTemplate* tp=GetNextDocTemplate(x);
		CSampleDoc* doc=NULL;
		if (tp!=NULL) {
				
			POSITION z=tp->GetFirstDocPosition( ); 
			
			if (z!=NULL)
				doc=(CSampleDoc* ) tp->GetNextDoc(z);

		}

		CSampleView * dview=NULL;
		if (doc!=NULL) {
			
			POSITION y=doc->GetFirstViewPosition(); 
			if (y!=NULL)
				dview=(CSampleView *) doc->GetNextView(y); 
		
			if (dview!=NULL) {
				dview->insertFile("Help.txt",101);

				pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
				//pMainFrame->UpdateWindow();

			}

		}
		

	}

	return TRUE;
}