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
| #include "stdafx.h"
#include "A Note.h"
#include "MainFrm.h"
#include <atlbase.h>
#include "DlgGuide.h"
#include "Picture.h"
#include <afx.h>
#include <afxwin.h>
#include <afxinet.h>
#include <atlbase.h>
#include <afxpriv.h>
#include "Base64.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BEGIN_MESSAGE_MAP(CANoteApp, CWinApp)
//{{AFX_MSG_MAP(CANoteApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CANoteApp::CANoteApp()
{
}
// GLOBAL FUNCTIONS AND THREADS --------------------------------
CANoteApp theApp;
// Get the application data path (where the notes.xml should be saved)
CString GetApplicationDataPath () {
CString szPath;
if (!SHGetSpecialFolderPath (NULL, szPath.GetBufferSetLength (MAX_PATH), CSIDL_APPDATA ,0)) {
// Something went wrong and we return the program path instead (maybe the user runs Windows 1.0 :) )
return GetProgramPath ();
}
szPath.Format (_T("%s\\A Note"), szPath);
// Create the directory if it doesn't exist
CreateDirectory (szPath, NULL);
return szPath;
}
// Get the program path
CString GetProgramPath ()
{
CString szTempPath, szTemp, szAppPath;
int i;
TCHAR buf[_MAX_PATH + 1];
::GetModuleFileName(NULL, buf, sizeof buf);
szTemp = buf;
i = szTemp.ReverseFind ('\\');
szAppPath = szTemp.Left ( i );
return szAppPath;
}
CString StringEncode(CString szText)
{
int iLength, iMultibyte;
CString szResult;
iLength = szText.GetLength ();
WCHAR *pwcUnicode = new WCHAR[sizeof (WCHAR) * (iLength + 1)];
char *pcDest = new char[2 * (iLength + 1)];
#if (defined (UNICODE) || defined (_UNICODE))
_tcscpy(pwcUnicode, szText);
#else
// To Unicode (form current codepage)
MultiByteToWideChar (CP_ACP, 0, szText, -1, pwcUnicode, iLength);
#endif
// To UTF-8
iMultibyte = WideCharToMultiByte (CP_UTF8, 0,pwcUnicode, iLength , pcDest, 2*iLength, NULL, NULL);
szResult = (CString) pcDest;
szResult = szResult.Left ( iMultibyte );
pcDest[iMultibyte] = '\0';
... |
Partager