Click here to Skip to main content
15,893,337 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDLL to VB callback help Pin
borono8-Apr-06 13:56
borono8-Apr-06 13:56 
AnswerRe: DLL to VB callback help Pin
Michael Dunn8-Apr-06 15:14
sitebuilderMichael Dunn8-Apr-06 15:14 
GeneralRe: DLL to VB callback help Pin
borono8-Apr-06 16:02
borono8-Apr-06 16:02 
GeneralRe: DLL to VB callback help Pin
Michael Dunn8-Apr-06 16:34
sitebuilderMichael Dunn8-Apr-06 16:34 
GeneralRe: DLL to VB callback help Pin
borono8-Apr-06 17:20
borono8-Apr-06 17:20 
GeneralRe: DLL to VB callback help Pin
Waldermort8-Apr-06 20:14
Waldermort8-Apr-06 20:14 
GeneralRe: DLL to VB callback help Pin
Waldermort8-Apr-06 20:24
Waldermort8-Apr-06 20:24 
GeneralRe: DLL to VB callback help Pin
borono9-Apr-06 4:35
borono9-Apr-06 4:35 
haha, no worries. I do have it working, here is what I did.

DLL Side:


#include <comdef.h>

template< class T >
BSTR ToBSTR( T a_Str )
{
     return( _bstr_t(a_Str).copy() ) ;
}


extern "C" void __stdcall stat( void (*cb) (u_short**) )
{
		char dao[100];  //way too much is better than way too little
	        sprintf(dao,"UDP: %d",udp); //do the work here, your faster
		BSTR l_Temp = ToBSTR(dao); // convert to BSTR
		BSTR bs = SysAllocString ( l_Temp ); //make it
		cb( &bs );  //send it
		SysFreeString ( bs ); //free it
		bs = NULL; //null it
}


VB Side:

Declare Sub stat Lib "mydll.dll" (ByVal funcptr As Long)
'
Sub CallbackFunction(ByRef numb As String)
    Form1.Label1.Caption = numb
End Sub


works great! computer saved. Smile | :)

best regards

-- modified at 10:37 Sunday 9th April, 2006

EDIT: thought it would be a good idea to include the conversion function, considering without it, this code is useless. Bold represents the modificiation.
GeneralRe: DLL to VB callback help Pin
Waldermort9-Apr-06 4:52
Waldermort9-Apr-06 4:52 
GeneralRe: DLL to VB callback help Pin
borono9-Apr-06 8:20
borono9-Apr-06 8:20 
QuestionThread is frozen Pin
LionAM8-Apr-06 12:51
LionAM8-Apr-06 12:51 
AnswerRe: Thread is frozen Pin
includeh108-Apr-06 19:07
includeh108-Apr-06 19:07 
AnswerRe: Thread is frozen Pin
Philipps8-Apr-06 20:13
Philipps8-Apr-06 20:13 
GeneralRe: Thread is frozen Pin
LionAM8-Apr-06 20:58
LionAM8-Apr-06 20:58 
QuestionTalking to a USB GPS device Pin
smikesmith8-Apr-06 12:23
smikesmith8-Apr-06 12:23 
AnswerRe: Talking to a USB GPS device Pin
Iain Clarke, Warrior Programmer8-Apr-06 12:54
Iain Clarke, Warrior Programmer8-Apr-06 12:54 
GeneralRe: Talking to a USB GPS device Pin
smikesmith8-Apr-06 13:00
smikesmith8-Apr-06 13:00 
GeneralRe: Talking to a USB GPS device Pin
Iain Clarke, Warrior Programmer8-Apr-06 13:07
Iain Clarke, Warrior Programmer8-Apr-06 13:07 
GeneralRe: Talking to a USB GPS device Pin
smikesmith8-Apr-06 13:15
smikesmith8-Apr-06 13:15 
QuestionQuestion about char* and __int32 Pin
big_denny_2008-Apr-06 11:43
big_denny_2008-Apr-06 11:43 
AnswerRe: Question about char* and __int32 Pin
Michael Dunn8-Apr-06 12:02
sitebuilderMichael Dunn8-Apr-06 12:02 
GeneralRe: Question about char* and __int32 Pin
big_denny_2008-Apr-06 23:23
big_denny_2008-Apr-06 23:23 
GeneralRe: Question about char* and __int32 Pin
Taka Muraoka9-Apr-06 3:36
Taka Muraoka9-Apr-06 3:36 
QuestionHow to paint from a memory DC to another memory DC Pin
Axonn Echysttas8-Apr-06 7:12
Axonn Echysttas8-Apr-06 7:12 
AnswerRe: How to paint from a memory DC to another memory DC Pin
includeh108-Apr-06 7:34
includeh108-Apr-06 7:34 

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.