Tools that can be used alone in ATL
Author: Carfield
Reprinted: http://blog.joycode.com/peon/ Reference: http://www.codeproject.com/atl/atlserver.asphttp://msdn.microsoft.com/library/default.asp?url=/library In addition to a large number of tools for making COM and Windows components in /US/vclib/html/vclrfatlserverreference.asp ATL7, we also provide a large number of tool classes that allow us to have more than half of the C programming. Most of Microsoft is a tool for GUI's tools. For component design and some service programming, it is unforgettable, and ATL has many tools that can be used as an Framework as an MFC. Class, greatly facilitate our programming, especially in ATL7, add a lot of such tools, let us: 1. The first thing to say is CString, everyone is natural to say, Only MFC can use unfortunately, and even becomes a reason why some people contain MFC in the ATL component, now it is also included in the ATL, as long as #include
{
Const char * szpassword = "Real9Video.rm TS = 2003-12-23-16-23-9";
CcryptProv ProV;
HRESULT HR = prov.initialize ();
IF (hr == 0x8009016L)
Prov.initialize (prov_rsa_full, null, ms_def_prov, crypt_newkeyset);
// This is actually similar to the code below
// ccryptKeyedhash Hash;
//hash.initialize (Prov, Calg_md5, CcryptKey :: EmptyKey, 0);
Ccryptmd5hash hash;
Hash.initialize (ProV);
Hash.addstring (szpassword);
Byte BUF [1024];
DWORD OUTLEN;
Hash.getValue (BUF, & OUTLEN);
Printhex (buf, outlen); // This is your own yourself, print the contents of the BYTE array
// should be BC CB 76 69 78 CF AB 4B 8 D E9 42 32 B0 88 9C
} 4. Encode and replacement, below is the conversion of Base64 and UTF8, to include Atlenc.h void base64 ()
{
CString ssource = "some string";
Int ndestlen = base64encodegetRequiredLength (ssource.getLength ());
CSTRING STR64;
Base64encode ((const byte *) (lpcstr) ssource, ssource.getlength (),
Str64.getBuffer (NDestlen), & ndestlen
Str64.releaseBuffer; Cout << (lpcstr) STR64;
Int ndeclen = base64decodegetRequiredLength; NDestlen;
CString Strorig;
Base64Decode (STR64, Str64.getlength (), (Byte *) Strorig.getBuffer (NDECLEN), & ndeclen
Strorig.releaseBuffer; NDECLEN
Cout << (lpcstr) Strorig;
}
Void UTF8Convert ()
{
Char buf [128];
MEMSET (BUF, 0, 128);
INT N = ATLUNICODETOUTF8 (L "Reic", 2, BUF, 128);
Printhex ((byte *) BUF, N);
}
5. CATLREGEXP regular expression tool, there is an example in MSDN, and CATLREGEXP <> regexp is also posted here.
CATLRematchContext <> mc;
// match any line what starts with any number of digits,
// Has a dash, and ends with any number of digits
IF ("^ // D - // D $") == repartse_error_ok)
{
Const char * sznumdashnum = "5663-4662";
IF (regexp.match (sznumdashnum, & mc)) {attrace ("matched");}
}