Click here to Skip to main content
15,908,768 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: encrypt and decrypt in UNICODE Pin
Rajesh R Subramanian18-Jan-07 20:07
professionalRajesh R Subramanian18-Jan-07 20:07 
GeneralRe: encrypt and decrypt in UNICODE Pin
Mark Salsbery19-Jan-07 5:59
Mark Salsbery19-Jan-07 5:59 
GeneralRe: encrypt and decrypt in UNICODE Pin
Mark Salsbery19-Jan-07 6:06
Mark Salsbery19-Jan-07 6:06 
GeneralRe: encrypt and decrypt in UNICODE Pin
Mark Salsbery19-Jan-07 6:19
Mark Salsbery19-Jan-07 6:19 
QuestionUSB Drive Pin
radhika2818-Jan-07 17:57
radhika2818-Jan-07 17:57 
AnswerRe: USB Drive Pin
Michael Dunn18-Jan-07 19:47
sitebuilderMichael Dunn18-Jan-07 19:47 
Questioncmd.exe bug / GetFileType from kernel mode Pin
Mike_V18-Jan-07 16:20
Mike_V18-Jan-07 16:20 
Questionhelp returning data from DLL Pin
Calvin Streeting18-Jan-07 13:36
Calvin Streeting18-Jan-07 13:36 
Hi i am writing a dll to proses msg files (sender,subject, etc). I managed to get right down to the IMessage Properties but i can't figure out how to return the value from my DLL.. This is my First c++ project (I know right in to the deep end MAPI and all, but it is better than MsgBox("hello world") Smile | :) )

Note the return value neads to be VB safe

CODE (See bit commented STUCK HERE)
/--------------------------------------------------------------------------------
#include <malloc.h>
#include "stdafx.h"
#include <mapi.h>
#include <mapix.h>
#include <mapiutil.h>
#include <ole2.h>
#include <imessage.h>

#define TEST_EXPORTS
#include "SSFILEDLL.h"

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
SSFILEDLL_API BSTR __stdcall Test()
{
HRESULT hr;
BSTR Message;

hr = MAPIInitialize(NULL);
if (FAILED(hr))
return "False";

hr = OleInitialize(NULL);
if (FAILED(hr))
return "False";

//get storage from msg file
LPSTORAGE pStorage= NULL;
hr = StgOpenStorage(L"C:\\Test\\2005-1~4.MSG",
NULL,
STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
NULL,
0,
&pStorage);
if (FAILED(hr))
return "False";
//Alloc memory
LPMALLOC pMalloc = MAPIGetDefaultMalloc();

//open a IMessage session
LPMSGSESS pMsgSession = NULL;

hr = OpenIMsgSession (pMalloc, 0 , &pMsgSession);
if (FAILED(hr))
return "False";

//open an IMessage on the IStorage object
LPMESSAGE pSourceMsg = NULL;
hr = OpenIMsgOnIStg(pMsgSession,
MAPIAllocateBuffer,
MAPIAllocateMore,
MAPIFreeBuffer,
pMalloc,
NULL,
pStorage,
NULL,
0,0,&pSourceMsg);
if (FAILED(hr))
return "False";
//ok can we get to the properties

SizedSPropTagArray(1, _attrs_) =
{
1,
{
PR_SUBJECT
}
};

LPSPropAttrArray lpAttributes = NULL;

hr = GetAttribIMsgOnIStg(
pSourceMsg,
(LPSPropTagArray)&_attrs_,
&lpAttributes
);
if (FAILED(hr))
{
return "False";
}
else
{

//STUCK HERE
//lpAttributes[0].cValues; should be the subject
//so how do i convert this to a BSTR (the way I have retrned data in the Past)

return Message;

MAPIFreeBuffer(lpAttributes);
}
//------------------------------------


if (pSourceMsg)
pSourceMsg->Release();
if (pMsgSession)
CloseIMsgSession(pMsgSession);
if (pStorage)
pStorage->Release();

MAPIUninitialize();
}
/--------------------------------------------------------------------------------

Many thnaks
QuestionRe: help returning data from DLL Pin
prasad_som18-Jan-07 17:30
prasad_som18-Jan-07 17:30 
AnswerRe: help returning data from DLL Pin
Calvin Streeting18-Jan-07 22:00
Calvin Streeting18-Jan-07 22:00 
QuestionProblem with my code - cant fine what wrong - please need help. Pin
Yanshof18-Jan-07 12:12
Yanshof18-Jan-07 12:12 
AnswerRe: Problem with my code - cant fine what wrong - please need help. Pin
Stephen Hewitt18-Jan-07 12:17
Stephen Hewitt18-Jan-07 12:17 
GeneralRe: Problem with my code - cant fine what wrong - please need help. Pin
prasad_som18-Jan-07 17:33
prasad_som18-Jan-07 17:33 
GeneralRe: Problem with my code - cant fine what wrong - please need help. Pin
Yanshof18-Jan-07 21:03
Yanshof18-Jan-07 21:03 
QuestionRe: Problem with my code - cant fine what wrong - please need help. Pin
prasad_som18-Jan-07 21:26
prasad_som18-Jan-07 21:26 
AnswerRe: Problem with my code - cant fine what wrong - please need help. Pin
Yanshof18-Jan-07 21:26
Yanshof18-Jan-07 21:26 
GeneralRe: Problem with my code - cant fine what wrong - please need help. Pin
prasad_som18-Jan-07 21:44
prasad_som18-Jan-07 21:44 
GeneralRe: Problem with my code - cant fine what wrong - please need help. Pin
Yanshof18-Jan-07 21:56
Yanshof18-Jan-07 21:56 
GeneralRe: Problem with my code - cant fine what wrong - please need help. Pin
prasad_som18-Jan-07 22:00
prasad_som18-Jan-07 22:00 
QuestionHow can I pass a pointer to a VARIANT to a function? Pin
Joan M18-Jan-07 10:35
professionalJoan M18-Jan-07 10:35 
AnswerRe: How can I pass a pointer to a VARIANT to a function?[modified] Pin
CPallini18-Jan-07 11:03
mveCPallini18-Jan-07 11:03 
GeneralRe: How can I pass a pointer to a VARIANT to a function?[modified] Pin
Joan M18-Jan-07 19:47
professionalJoan M18-Jan-07 19:47 
GeneralRe: How can I pass a pointer to a VARIANT to a function?[modified] Pin
CPallini18-Jan-07 21:03
mveCPallini18-Jan-07 21:03 
AnswerRe: How can I pass a pointer to a VARIANT to a function? Pin
Stephen Hewitt18-Jan-07 12:12
Stephen Hewitt18-Jan-07 12:12 
GeneralRe: How can I pass a pointer to a VARIANT to a function? Pin
Joan M18-Jan-07 19:46
professionalJoan M18-Jan-07 19:46 

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.