jeudi, janvier 28

Comment débloquer les services Windows

Cet article est basé d'un autre article de Microsoft (lien). n'oublie pas tes PBS. ils doivent être disponibles.

1. Ajoute une clé dans la base de registre

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MonService.exe

2. Ajoute une valuer de type REG_SZ ci-dessus et appelle-le "Debugger"

3. Il faut modifier la valuer à ..

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe /debugexe "MonService.exe" si tu utilises visual studio 2005 ou

C:\Program Files\Debugging Tools for Windows (x86)\windbg.exe si tu utilises WINDBG à sa place

4. Pour que Visual Studio 2005 lancera après le service commence

5. De Visual Studio, ouverte les fichiers sources C++. Mis des points d'arret (breakpoints) etc.

6. Voila F5 pour commencer débloquer.

7. Au fait, tu peux utiliser DebugBreak() pour dire le system que tu veux un point d'arrêt quelque part comme ci-dessus ..

#ifdef _DEBUG
DebugBreak();
#endif

mardi, janvier 26

BOOST serialisation

boost is an open source C++ library which I am just beginning to appreciate. one of the cool things found in this library is the ability to serialize an object to xml and back. in my project, I needed to serialize simple types (std::strings and integers) and arrays (vectors). here's how ..

first, add the serialize method. there are certain limitations, i discovered, to what kind of data types you can serialize. (or better if there is someone who could educated me). i was originally trying to serialize an AtlArray and ATL::CString but i was forced to use the standard vector instead. as STL seems to work very well with boost.

remarque aussi que les headers ont besoin d'encadrer par des parenthèses comme d'hab ..

#include vector
#include boost/serialization/vector.hpp
class CEnchantementDeck : public CMagicDeck
{
public:
CEnchantementDeck(void);
template class Archive // class Archive is enclosed in brackets
void serialize(Archive& ar, const unsigned int version)
{
ar & boost::serialization::make_nvp("Créatures", m_arrayCreatures);
ar & boost::serialization::make_nvp("Rituels", m_arrayRituels);
ar & boost::serialization::make_nvp("Enchantements", m_arrayEnchantments);
ar & boost::serialization::make_nvp("Ephémères", m_arrayEphemeres);
ar & boost::serialization::make_nvp("Alpenteurs", m_arrayAlpenteurs);
ar & boost::serialization::make_nvp("Terrains", m_arrayTerrains);
}
bool Save(const ATL::CString& strFile);
bool Load(const ATL::CString& strFile);
private:
std::vector CCreature m_arrayCreatures; // CCreature is enclosed in brackets
std::vector CRituel m_arrayRituels; // CRituel is enclosed in brackets
std::vector CEnchantement m_arrayEnchantments; // and so on and so forth ..
std::vector CEphemere m_arrayEphemeres;
std::vector CAlpenteur m_arrayAlpenteurs;
std::vector CTerrain m_arrayTerrains;
}

next is how to load the serialised object. not that i am now using another part of boost called archive.

#include fstream
#include boost/archive/text_iarchive.hpp
#include boost/archive/text_oarchive.hpp
#include boost/archive/xml_woarchive.hpp
#include boost/archive/xml_wiarchive.hpp
bool CEnchantementDeck::Load(const ATL::CString& strFile)
{
bool bSuccess = true;
try
{
std::wifstream input;
input.open(strFile);
boost::archive::xml_wiarchive archive(input);
archive >> boost::serialization::make_nvp(
"Mon deck", *this);
}
catch(...)
{
bSuccess = false;
}
return bSuccess;
}

and how to save a serialised object. it is as simple as that ..

bool CEnchantementDeck::Save(const ATL::CString& strFile)
{
bool bSuccess = true;
try
{
std::wofstream output;
output.open(strFile);
boost::archive::xml_woarchive archive(output);

archive << boost::serialization::make_nvp(
"Mon deck", *this);
}
catch(...)
{
bSuccess = false;
}
return bSuccess;
}

to use the class, just instantiate and populate like so. of course, you guys need to fill in the access methods yourselves.

CEnchantementDeck oDeck;
oDeck.Charge("c:\mes decks\enchantment.xml");
oDeck.AjouteEnchantement("Honneur des purs");
oDeck.AjouteEphemere("Chemin vers l'exil");
oDeck.SupprimerAlpenteur("Elspeth Chevalière Errant");
oDeck.Sauvgarde("c:\mes decks\enchantment.xml");

mercredi, janvier 20

avec qui sors-tu ce soir?

la date au format francais est dd/mm/yy (20 janvier 2010) et la date au format americain est mm/dd/yy (january 20, 2010). si tu lances le program et tu prefères de montrer les dates et les montants (quantities) au format particulier, tu peux utiliser les fonctions suivants pour faire ça.

::GetLocaleInfo() permis d'obtenir les parametres actuel
_tsetlocale() permis de modifier la locale

// Sets the locale to the default, which is the user-default ANSI code
// page obtained from the operating system.
_tsetlocale(LC_ALL, L"");

TCHAR szBuf[_MAX_PATH] = { 0 };
TCHAR szLocale[_MAX_PATH] = { 0 };

::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, szBuf, _MAX_PATH);
_tcscpy(szLocale, szBuf);

::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SENGCOUNTRY, szBuf, _MAX_PATH);
if (_tcsclen(szBuf) != 0)
{
_tcscat(szLocale, _T("_"));
_tcscat(szLocale, szBuf);
}

::GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE, szBuf, _MAX_PATH);
if (_tcsclen(szBuf) != 0)
{
_tcscat(szLocale, _T("."));
_tcscat(szLocale, szBuf);
}

// e.g. szLocale = "English_United States.1252"
// Set the locale
_tsetlocale(LC_ALL, szLocale);


Voici le code pour montrer la date actuel

time_t lt;
time (<);
tm* timeptr = localtime (<);
if (timeptr)
{
wchar_t szDate[_MAX_PATH] = {0};
wchar_t s[_MAX_PATH] = {0};

// Date representation for current locale
wcsftime(szDate, _MAX_PATH, _T("%x %X"), timeptr);
wcscpy (s, szDate);

wstrCurrDate = s;
}


Si la date disponible est un DBTIMESTAMP?

// Convert DBTIMESTAMP to COleDateTime
// DBTIMESTAMP stamp
// Set locale first
COleDateTime d(stamp.year,
stamp.month,
stamp.day,
stamp.hour,
stamp.minute,
stamp.second);

// Convert COleDateTime to CAtlString
CString strStamp = d.Format(L"%x %X");

std::wstring wstrDate(strStamp);

je ne peux pas vivre sans livres

looking for richards dawkins' the extended phenotype which follows his earlier work on la gene egoiste.

i highly recommend his other books which i am giving away for free. there is only one catch. that the recipient would promise to do same. i mean give it away for free to someone else who is interested and pass it along to the next. i wonder how far it will go.

the greatest show on earth - about evidences of evolution
god delusion - about the nature of belief/religion
selfish gene - about the mechanism of evolution

samedi, janvier 16

une quéquette blanche allié

worldwake spoiler here

as-tu vu le nouveau allié le paladin de talos (ravine paladin en anglais)?!?!? tous les créatures vont avoir du lien de vie!! siiiiiiiiiiiiiii gai. on peut imaginer la voix de quelqu'un me dit. héhé. il y a d'autres alliés blancs qui sont super. avec tant des alliés qui deviennent très fort avec +1/+1 marqueurs, il n'y a plus besoin de l'honneur des purs.

pour mon deck des enchantements, je pense d'jouter le couleur noir pour quest for the nihil stone et howling mines viennent à l'ésprit.

parce que j'ai décidé que je vais me concentrer sur ces deux decks. alliés et enchantements.

en attendant, depuis worldwake n'est pas disponible jusqu'a le debut de février, voici mon deck alliés qui était me donné par taz. pour maintenant un peu ... je utilise les couleurs de naya (rouge, blanc, et vert).

les créatures

4 highland berserker 1R
4 ondu cleric 1W
4 oran-rief survivalist 1G
4 kazandou blademaster WW
4 kabira evangel 2W
4 turn-timber ranger 3RR
4 kazuul warlord 4R --> 2 serait plutot paladin de talos

les éphémères/rituels

4 path to exile
4 lightning bolt
3 beast hunt 3G --> serait plutot join the ranks

les terrains

2 rootbound crag
4 jungle shrine
4 arid mesa
2 terramorphic expanse
2 sunpetal grove
3 Plaines
3 forets
3 montagnes

reserve

2 luminarch ascension contre control
3 pithing needle contre des arpenteurs
3 journey to nowhere contre grands créatures
3 mark of asylum contre fromage (keso!! haha!)
4 jour de condamnation contre grands armées

l'autonomie personelle

j'ai repéré cette livre en solde au tournoi le dernier weekend pour seulement 200 PHP. je suis content que je l'a acheté. sa (jon b. eisenberg) perspicacité sur le cas shaivo, la trace documentaire au religious right et leur amis en gouvernement qui sont financé bien - les républicains, leur mensonges et leur points non scientifique de vue à propos de ANH (artificial nutrition and hydration) et des gens qui sont PVS (persistent vegetative state), leur objectif ultime pour changer l'amerique vers une théocracie -- sont tous fascinante et effrayant.

personal autonomy. government and certainly churches should have no business when deciding on something as intimate as letting go of a loved one who is no longer. it is no laughing matter reading about how entrenched churches are in the government. the issue is really a lot bigger than the shaivo case. it extends to other social issues (pro-choice, gay rights, etc) as well, where they mean to impose their religious values ultimately onto the rest of us. despite this, i am hopeful that the existing check and balance in the governement (in the name of the judiciary) is there to protect our rights.

dimanche, janvier 10

le plus important spectacle

je viens du lire the greatest show on earth par richard dawkins. un livre science qui parle des preuves d'evolution et aussi en bref instant de ceux qui démentent l'histoire. je suis persuadé que l'evolution est un fait. c'est sans doute. si on regarde des preuves qui sont présenté par la geologie (geological strata which shows fossils from different ages of geological time, the approximate age of the earth and the universe), la biologie moléculaire (DNA and RNA signature), et bien sur, le bien connu science de archéologie (fossil records).

interesting parts:

1. when they demonstrated evolution in the lab. it is ultimately evolution right before our eyes one could say. over test tubes of carefully documented generation after generation of bacteria which did show slight variant improvments in the organisms ability to consume food.

2. understanding of how speciation works by having two populations evovle separately by non random natural selection and mutation.

3. how radiometric dating of materials works and various other methods of dating are evidence of the earth being a lot of times older than biblical accounts which is 6,000 years old. creationists, who despite the glaring evidence, would outright deny it without thought.

4. understanding of fossil records discovered in geological strata where each section hold only certain types of fossils and no other from later sections. and how it points to evolution.

je le recommande à tous!!

vendredi, janvier 8

WTL DoDataExchange

C'est vendredi encore. La première semaine de l'année. on ne peut pas aider mais réfléchit à l'année passée. 2009 était sensationnel et tragique. c'était quand j'ai perdu un copain (taureau) mais peut-être c'était pour le mieux parce qu'il était toujours en colère (contre tous) et nous étions en désaccord sur presque tout. je suis si content quand la relation a fini. c'était aussi quand j'ai vraiment perdu mon innocence à quelqu'un qui j'aime mais il n'est pas disponible. bien sur, je l'ai perdu quand j'avais 21 ans, mais c'est maintenant que je me suis senti qu'il est finalement arrivé.pour la première fois dans ma vie, je m'amuse faire l'amour où comme avant, j'en avais peur.

Back to WTL. Just like MFC, WTL is able to attach (as in read from and save to) a dialog's member control via DDX.

1. Include atlddx.h and derive from CWinDataExchange

#include "atlwin.h"
#include "atlddx.h"
#include "resource.h"

class CCreateJobDlg :
public CAxDialogImpl,
public CWinDataExchange
{
... quelque chose
}


2. Just like the entries inside DoDataExchange().

BEGIN_DDX_MAP(CCreateJobDlg)
DDX_TEXT(IDC_EDIT_JOB, m_szName)
DDX_CONTROL_HANDLE(IDC_EDIT_JOB, m_editName)
END_DDX_MAP()

CEdit m_editJobName;


3. Then call DoDataExchange(FALSE) from OnInitDialog(). This is like UpdateData(FALSE) from MFC which attaches the resource

to the control as specified in the DDX map and loads data into the control.

LRESULT CCreateJobDlg::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&)
{
// Load
DoDataExchange(FALSE);
m_editName.SetWindowText(_T("Bonjour!"));
m_editName.SetSelAll();
m_editName.SetFocus();

// return TRUE unless you set the focus to a control
return FALSE;
}


4. To read data from the control, we call DoDataExchange(TRUE).

LRESULT CCreateJobDlg::OnOK(UINT, WPARAM, LPARAM, BOOL&)
{
DoDataExchange(TRUE);
// Fais quelque chose avec m_szJobName/m_editName
}

jeudi, janvier 7

WTL Enable resize a dialog

tout d'abord, bonne année 2010!! j'ai passé la fin d'année avec taz qui était assez gentil pour me permettre à rester dans leur appartement pendant les jours fériés.

I am just starting to appreciate WTL (Windows Template Library). Having developed software for more than a decade using MFC and later C#.NET, I was skeptical about WTL. So far, it is difficult finding a published book on the subject. Thank goodness for C++ developers out there who had been kind enough to post their sample works on the internet.

I am also trying out this cool tip on how to post source code on blogspot. Thanks to Vivian.

1. Derive from CDialogResize.

class CMainDlg : public CDialogImpl,
public CDialogResize
{
// Put maps here
}


2. Specify the chain message map entry for CDialogResize.

BEGIN_MSG_MAP(CMainDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
CHAIN_MSG_MAP(CDialogResize)
REFLECT_NOTIFICATIONS()
END_MSG_MAP()


3. Specify the behaviour of resize for each control in the dialog resize map. DLSZ_SIZE_Y means the control would grow vertically and DLSZ_SIZE_X horizontally.

BEGIN_DLGRESIZE_MAP(CMainDlg)
DLGRESIZE_CONTROL(IDC_TREE_JOBS, DLSZ_SIZE_Y)
DLGRESIZE_CONTROL(IDC_LIST_PIPEELEMENTS, DLSZ_SIZE_X | DLSZ_SIZE_Y)
END_DLGRESIZE_MAP()


4. Initialize CDialogResize

LRESULT CMainDlg::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&)
{
// Init the CDialogResize code
DlgResize_Init();

// center the dialog on the screen
CenterWindow();


As you can see, it does feel like a cross between Win32 API and MFC programming. I liken it to a missing link - the next evolutionary step. As homo sapiens departed from their monkey-like ancestors, WTL departed from its bulky roots and became better in terms of binary output size. The sad news is, as with many species in geological time, some die out. Having heard that MS had long since discontinued support for the technology, I do not see any future for WTL. C'est triste.

I can imagine that it would be extremely difficult for someone who does not have experience in both to pick up WTL. But at the same time, I remember being horrified at Win32 API back in the days of Windows 95. We were even debating whether we ought to use Win32 or stick to what we knew, which at that time, was Turbo C. Had I known then how easy it was to use Win32 I would have seceeded from the argument.

The same could be said today only the debate (in my head) is between MFC and WTL.