Click here to Skip to main content
15,911,132 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: CListViewCtrl creation does not produce column header arrow indicating sort order Pin
Jonathan Davies18-Jan-09 11:34
Jonathan Davies18-Jan-09 11:34 
QuestionHow to achieve receiving file name using ICopyHook interface? Pin
SNI14-Jan-09 23:00
SNI14-Jan-09 23:00 
AnswerRe: How to achieve receiving file name using ICopyHook interface? Pin
Stuart Dootson17-Jan-09 23:01
professionalStuart Dootson17-Jan-09 23:01 
AnswerRe: How to achieve receiving file name using ICopyHook interface? Pin
gopu7418-Nov-09 5:53
gopu7418-Nov-09 5:53 
GeneralATL COM and DLL comparision........... [modified] Pin
vijay.victory13-Jan-09 23:52
vijay.victory13-Jan-09 23:52 
GeneralRe: ATL COM and DLL comparision........... Pin
Stuart Dootson14-Jan-09 10:37
professionalStuart Dootson14-Jan-09 10:37 
QuestionBSTR=> CHARACTER ARRAY => BSTR conversion Pin
CHAN_SAI13-Jan-09 22:54
CHAN_SAI13-Jan-09 22:54 
AnswerRe: BSTR=> CHARACTER ARRAY => BSTR conversion Pin
Stuart Dootson13-Jan-09 23:54
professionalStuart Dootson13-Jan-09 23:54 
It's probably not wise to treat an encrypted message as a character stream - I would suggest you treat it as a stream of bytes instead - which, to be honest, is what unsigned chars usually represent in C/C++.

In fact, I wouldn't bother to convert from BSTR to unsigned char using a charset->charset mapping. I would just treat the BSTR as a set of bytes (aka unsigned chars). You can do this as shown in this sample program:

#include <windows.h>
#include <oleauto.h>
#include <iostream>
#include <iterator>

#pragma comment(lib, "oleaut32")

int main(int argc, char** argv)
{
   const wchar_t* s = L"Hello World";
   BSTR bs = SysAllocStringLen(s, lstrlenW(s));
   
   unsigned char *byteStream = (unsigned __int8 *)bs;
   ULONG byteCount = SysStringByteLen(bs);
   
   std::cout << "byteCount = " << byteCount << std::endl;
   std::cout << "bs (in bytes) = ";
   for(unsigned char * p=byteStream;p!=byteStream+byteCount;++p)
        std::cout << std::hex << (int)(*p) << " ";
   std::cout << std::endl;
}


This shows the bytes that make up the BSTR. You can then encrypt that set of bytes.

If you are returning a BSTR because it's an easy to use container, you can create a BSTR from a set of bytes as follows:

unsigned char *encryptedByteStream;
ULONG encryptedByteCount;
// Perform the encryption - let's assume you set encryptedByteStream as the
// first encrypted byte, encryptedByteCount is the number of encrypted bytes.

BSTR outputBS = SysAllocStringByteLen(encryptedByteStream, encryptedByteCount);


HTH!!
GeneralRe: BSTR=&gt; CHARACTER ARRAY =&gt; BSTR conversion Pin
CHAN_SAI14-Jan-09 14:37
CHAN_SAI14-Jan-09 14:37 
GeneralRe: BSTR=&gt; CHARACTER ARRAY =&gt; BSTR conversion Pin
Stuart Dootson14-Jan-09 20:56
professionalStuart Dootson14-Jan-09 20:56 
QuestionATL_MSG_MAP identifier not found Pin
josip cagalj13-Jan-09 0:57
josip cagalj13-Jan-09 0:57 
AnswerRe: ATL_MSG_MAP identifier not found Pin
Stuart Dootson13-Jan-09 4:09
professionalStuart Dootson13-Jan-09 4:09 
GeneralRe: ATL_MSG_MAP identifier not found Pin
josip cagalj13-Jan-09 21:18
josip cagalj13-Jan-09 21:18 
GeneralRe: ATL_MSG_MAP identifier not found Pin
Stuart Dootson13-Jan-09 21:29
professionalStuart Dootson13-Jan-09 21:29 
QuestionRe: ATL_MSG_MAP identifier not found Pin
josip cagalj13-Jan-09 22:57
josip cagalj13-Jan-09 22:57 
AnswerRe: ATL_MSG_MAP identifier not found Pin
josip cagalj13-Jan-09 23:13
josip cagalj13-Jan-09 23:13 
AnswerRe: ATL_MSG_MAP identifier not found Pin
Stuart Dootson13-Jan-09 23:23
professionalStuart Dootson13-Jan-09 23:23 
GeneralRe: ATL_MSG_MAP identifier not found Pin
josip cagalj13-Jan-09 23:35
josip cagalj13-Jan-09 23:35 
GeneralRe: ATL_MSG_MAP identifier not found Pin
Stuart Dootson13-Jan-09 23:43
professionalStuart Dootson13-Jan-09 23:43 
GeneralRe: ATL_MSG_MAP identifier not found Pin
josip cagalj14-Jan-09 2:51
josip cagalj14-Jan-09 2:51 
GeneralRe: ATL_MSG_MAP identifier not found Pin
Stuart Dootson14-Jan-09 3:29
professionalStuart Dootson14-Jan-09 3:29 
Questionwhat is the event i should use Pin
prasadbuddhika7-Jan-09 23:05
prasadbuddhika7-Jan-09 23:05 
QuestionHow to get timer id from onTimer() in WTL Pin
josip cagalj7-Jan-09 22:05
josip cagalj7-Jan-09 22:05 
AnswerRe: How to get timer id from onTimer() in WTL Pin
Stuart Dootson7-Jan-09 22:48
professionalStuart Dootson7-Jan-09 22:48 
GeneralRe: How to get timer id from onTimer() in WTL Pin
josip cagalj7-Jan-09 22:58
josip cagalj7-Jan-09 22:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.