As I posted earlier this week, I was about to write a small starter application that would do all the necessary changes to the notes.ini when you have a notes installation on an usb key. Well here it is: nstart.exe
When you plug in your usb key to a different computer, you cannot be sure to have the same drive letter for your usb device than before.
In this case your Notes won’t start and you have to tweak the notes.ini manually.
Copy nstart.exe to the notes root directory. When you double click nstart.exe, the tool will set all occurencies of drives ( for example e:\ ) to your current drives letter and then start notes.exe.
The code is still very beta; it should have more error handling, I know. But I decided to release the code in this very early state. The code works for me but maybe not for you. So please give me a feedback when you find the code useful. Even if you think this stuff is crap, please let me know. And if you find errors ( and I’m sure you will ) just leave a comment.
// nstart.cpp
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "nstart.h"
#include "CPathSplit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
#define NOTES_INI "notes.ini"
#define NOTES_PRG "notes.exe"
#define BACKSLASH ":\\"
CWinApp theApp;
CFile* fin = NULL;
CFile* fout = NULL;
CFileException ex;
CString Drives ="CDEFGHIJKLMNOPQRSTUVWXYZcdefghijklmnopqrstuvwxyz";
char AppPath[MAX_PATH];
int i, n, j;
using namespace std;
/////////////////////////////////////////////////////////////////////////////
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
cerr < < _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
try
{
GetModuleFileName(AfxGetApp()->m_hInstance,AppPath,MAX_PATH);
CString l_oStrPath = AppPath;
CPathSplit l_oPathSplit(l_oStrPath);
CString l_oStrFileExt;
CString l_oStrPathCustom;
l_oStrFileExt = NOTES_INI;
l_oStrPathCustom = l_oPathSplit.GetPath(ePATHEL_DIRECTORY, & l_oStrFileExt);
CString BS(_T(BACKSLASH));
CString strPath(AppPath);
CString ThisDrive (strPath.Left(1) + BS);
fin = new CFile( l_oStrPathCustom, CFile::modeRead | CFile::shareDenyNone);
ULONGLONG dwLength = fin->GetLength();
char pbuf[99999] = {dwLength}; // read NOTES.INI
UINT nBytesRead = fin->Read( pbuf,dwLength );
fin->Close();
CString buffer(pbuf);
// replace drive letters with current drive
for (i=0; i < Drives.GetLength() ; i++) {
CString DriveLetter (_T(Drives.GetAt(i) + BS));
j = buffer.Replace(_T(DriveLetter), _T(ThisDrive));
}
// write notes.ini
fout = new CFile( l_oStrPathCustom ,CFile::modeWrite | CFile::shareDenyWrite);
fout->Write(_T(buffer),dwLength);
fout->Flush();
fout->Close();
// start the client
l_oStrFileExt = NOTES_PRG;
l_oStrPathCustom = l_oPathSplit.GetPath(ePATHEL_DIRECTORY, & l_oStrFileExt);
ShellExecute(0, "open", l_oStrPathCustom, 0, 0, 1);
}
catch (CFileException* pEx)
{
// if an error occurs, just make a message box
pEx->ReportError();
pEx->Delete();
nRetCode = 1;
}
catch (...)
{
nRetCode = 1;
}
return nRetCode;
}
Download Source