|
read the posting guidelines[^], especially when you post huge code blocks.
Calvin Streeting wrote: Pass a sting
wow, that'll be hard
|
|
|
|
|
I was under the impression that VB strings were wide/Unicode by default, and would be in the form of a BSTR (BSTR == B ASIC Str ing, IIRC), which is already a wide string.
You can pass a BSTR in place of a const wchar_t* or const WCHAR* just fine. As far as how to get that BSTR directly to the function in the DLL, I cannot help you there - I do not do VB, nor am I 100% certain that the internal format of the BSTR is exactly the same as its external/COM format.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I thought so but if I...
SSFILEDLL_API bool __stdcall OpenEmail(BSTR FileName)
then the StgOpenStorage fails but if i hard code in the filename L"c:\\email.msg" it works...
am i missing some thing
|
|
|
|
|
StgOpenStorage(...) fails when? At compile time, at run time, and with what error? Oh, and that should be a const BSTR parameter - you are not going to modify it so it can be constant.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
if i use "const BSTR filename" it compiles ok but fails at run time (StgOpenStorage(..) returns -2147287038) when called. it also sometimes crashes the vb app.
Many thanks for your help
|
|
|
|
|
Examine the string in the debugger (run the DLL under the debugger by specifying the VB application as the executing application), and see if the string looks valid or not.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
ok now you are hitting the limit of my c++ (this is my first c++ program ).. i feel i might need to read the section on debuging... but for you info it shows
szString = 0x0013c884
|__ 12849
which i take it is ram address?... is there any way to get it to print out the BSTR or msgbox it....
calvin
|
|
|
|
|
You need your debugger configured to show Unicode strings, and that will allow you to see if the value you are seeing can be treated as a BSTR or not.
You can use MessageBoxW(...) to see the value by doing something like this:
::MessageBox<code>W</code>( szString, L"The String", MB_OK ); Pay attention to the "W" in ::MessageBoxW(...) . The call to MessageBoxW will either show the contents of the string (if the string pointer is valid), or will likely crash or show garbage if not.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi.. I found out that bit about setting debuger options and have done it (thanks for the clue) and i have found that
szString = 0x0013D374 ??????g
so i used the memory tool (learning how to debug, this is simular to pic asm) and found the memory and it says
0013D374 43 3A 5C 5C 65 6D 61 69 6C 2E 6D 73 67 00 00 00 0D C:\\email.msg....
so am i right in thinking it is not getting through... so back to google
Many thanks for you help i will "Please rate this message - let me know if I helped or not!" once i have this working, infact even if i don't as you have been very helpfull
|
|
|
|
|
Ok finaly got it....
convert
1. Pass Char * from vb to C++
2. covnvert to BSTR
3. Pass to StgOpenStorage(...)
reason vb passed a "8 bit ANSI string" function wanted a "Wide UNICODE string"
see below
SSFILEDLL_API bool __stdcall OpenEmail(char *FileName)
{
if (bIsopen == false)
{
HRESULT hr;
hr = MAPIInitialize(NULL);
if (FAILED(hr))
return false;
hr = OleInitialize(NULL);
if (FAILED(hr))
return false;
//convert Char * to BSTR
BSTR bFileName;
int count = 0;
count = MultiByteToWideChar(CP_ACP, 0, szString , strlen(szString), NULL , 0);
if(count > 0) {
bFileName = SysAllocStringLen(0, count);
MultiByteToWideChar(CP_ACP, 0, szString , strlen(szString), bFileName , count);
}
//get storage from msg file
hr = StgOpenStorage(bFileName ,
NULL,
STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
NULL,
0,
&pStorage);
if (FAILED(hr))
{
return false;
}
else
{
return true;
}
}
else
{
return false;
}
}
once again many thanks, it works, it works
err ok what was next
for your information this code is for http://ssfiledll.sourceforge.net/
-- modified at 19:52 Monday 22nd January, 2007
|
|
|
|
|
I am looking for VC++ code on how to drag a rectangle. It must not be Managed C++. But something that will work with VS2003.
I have seen such code somewhere here on CodeProject but multiple searches hasn't revealed anything.
Anybody that can direct me please?
I am the handsome one in the crowd.
|
|
|
|
|
hello everybody,
My name is Srikanth.I am new to the discussion board.I have a problem in My application ie, i cant play ogg files. when i am rewinding or forwarding the file then an error is occuring and the error is "couldnt read from specified memory location" and i tried to find it but my effort was in vain. So I am in very much need of ur help.kindly help me.
srikanthrao
|
|
|
|
|
Hi everyone,
in a big appliaction, we have certainly 50 different Windows.
My application is an MDI-Style. So i need for example 50 CMultiDocTemplates for f.ex. 50 different MDI-Frames.
Is it the right way or is it easier to create dynamically an Frame and there'in creating his View ?
In all examples and books it's explained with Templates but is it also
used in professional-life ?
Thanks a lot
-- modified at 7:23 Monday 22nd January, 2007
|
|
|
|
|
i want a ebook i.e. soft copy of book on ATL COM , so please send me a link or book on my mail is tosachingupta@yahoo.com
|
|
|
|
|
Hello Sachin!
I've e-book of ATL. If u want it, come online at
jubinc@skype.
Come online at:-
jubinc@skype
|
|
|
|
|
hi,
can you mail me the book as well at je_shoaib@hotmail.com
thanks
|
|
|
|
|
Hi ,
I have a embededVC code something like this:
DWORD wc = WaitForMultipleObjects(
sizeof(hObjectList)/sizeof(HANDLE), // number of handles in array
hObjectList, // object-handle array
FALSE, // wait option
(DWORD) INFINITE // time-out interval
);
switch ( wc)
{
case WAIT_OBJECT_0:
break;
case WAIT_OBJECT_0 + 1: //Center button
if (WaitForSingleObject(hCenterState,0)==WAIT_OBJECT_0)
{
/*hCenterState button pushed*/
::SendMessage(hWnd,WM_TRIGGER_PULL,0,0);
}
break;
}
the above code is in a function which is on a thread (obviously) ...(. thread is initiaited on WM_INITDILAOG of the dialog.I pass the dialog handle to the creathread function)
Problem is that the SendMessage function posts a message WM_TRIGGER_PULL only for the first time i open the dialog.If i exit the dialog and then open it again , this time the SendMessage does not post the WM_TRIGGER_PULL message.
i cant get y it cant post the msg the second time.
Any body has solution to this is most welcome with a reply.
thanks in Advance
|
|
|
|
|
Please stop reposting.
Post a question once only, else people will ignore them.
|
|
|
|
|
|
|
And whats your question ?
|
|
|
|
|
|
how to map my database(ms -access)
to my project which is online
thanking u
bye
bye
|
|
|
|
|
Hi
Beginer question (I think;) - how to make my CListView columns (I use a report view) to fill in all available list width? (without adding scrollbar control at the bottom).
When I use m_ListView.GetClientRect() and then set my two columns width to the 1/2 of the returned value, I still get a scroll bar at the bottom...?!? (couple of pixels, but still...)
Is it possible to remove the last column's separator?? I could just shrink last column by 2-4 pixels and remove its ending separator to look nice;) How to do it??
Thanks for any help/comment.
|
|
|
|
|
PatrykDabrowski wrote: Is it possible to remove the last column's separator?? I could just shrink last column by 2-4 pixels and remove its ending separator to look nice;) How to do it??
You can use SetColumnWidth or specify the width when creating columns.
|
|
|
|