Click here to Skip to main content
15,895,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: RegQueryValueEx Problem! Pin
krmed18-Dec-06 2:53
krmed18-Dec-06 2:53 
AnswerRe: RegQueryValueEx Problem! Pin
Hamid_RT18-Dec-06 0:05
Hamid_RT18-Dec-06 0:05 
AnswerRe: RegQueryValueEx Problem! Pin
kakan18-Dec-06 0:16
professionalkakan18-Dec-06 0:16 
QuestionUnhandled execption in ariel.exe(APIOCX):0xC0000005 :Access violation Pin
With_problem17-Dec-06 21:42
With_problem17-Dec-06 21:42 
Questionconverting unsigned char array to bstr Pin
dekta17-Dec-06 20:54
dekta17-Dec-06 20:54 
AnswerRe: converting unsigned char array to bstr Pin
CPallini17-Dec-06 23:02
mveCPallini17-Dec-06 23:02 
GeneralREpost : converting unsigned char array to bstr Pin
dekta18-Dec-06 16:08
dekta18-Dec-06 16:08 
GeneralRe: REpost : converting unsigned char array to bstr Pin
CPallini18-Dec-06 23:57
mveCPallini18-Dec-06 23:57 
the following code works (though I cannot figure why do you want to do this kind of stuff...)
DLL side:
extern "C"
{
	VARIANT WINAPI MyString(void)
	{
		
	
		unsigned char vst[21] = 
		{
			0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00,
			0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00, 0x17, 0xFF, 0x00,
			0x00 // null
		};

		OLECHAR olec[21];
	
		MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, (LPCSTR)&vst, 21, (LPWSTR) olec, 21);
		
		VARIANT vt;
		VariantInit( &vt );
		vt.vt = VT_BSTR;
		vt.bstrVal = SysAllocStringLen(olec, 21);
		return vt;
	}
}


VB side:

Private Declare Function MyString Lib "DllString" () As Variant


Private Sub Form_Load()
  Dim n As Long
  Dim p
   
  p = MyString()
   
  For n = 1 To Len(p)
    Debug.Print Asc(Mid(p, n, 1))
  Next
  
End Sub


and finally, the output (Immediate Window)
0
23
255
0
23
255
0
23
255
0
0
23
255
0
23
255
0
23
255
0
0



I have used VARIANT type to encapsulate the string because Visual Basic makes some kind of translation over the strings whenever it passes to Windows-Like API exported by DLLs.


Hope that helps.


If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

Questiondetecting the FTP connection break down. Pin
vijay_aroli17-Dec-06 20:31
vijay_aroli17-Dec-06 20:31 
GeneralRe: detecting the FTP connection break down. Pin
Mila02517-Dec-06 20:40
Mila02517-Dec-06 20:40 
GeneralRe: detecting the FTP connection break down. Pin
vijay_aroli17-Dec-06 20:52
vijay_aroli17-Dec-06 20:52 
GeneralRe: detecting the FTP connection break down. Pin
Mila02517-Dec-06 21:03
Mila02517-Dec-06 21:03 
GeneralRe: detecting the FTP connection break down. Pin
vijay_aroli17-Dec-06 21:31
vijay_aroli17-Dec-06 21:31 
Questionwhat is best compiler Pin
siaswar17-Dec-06 20:29
siaswar17-Dec-06 20:29 
AnswerRe: what is best compiler Pin
Cedric Moonen17-Dec-06 20:48
Cedric Moonen17-Dec-06 20:48 
GeneralRe: what is best compiler Pin
siaswar17-Dec-06 21:00
siaswar17-Dec-06 21:00 
GeneralRe: what is best compiler Pin
Cedric Moonen17-Dec-06 21:25
Cedric Moonen17-Dec-06 21:25 
QuestionDialog box is not getting displayed [modified] Pin
Dinu_IP17-Dec-06 19:44
Dinu_IP17-Dec-06 19:44 
Questionassembly Pin
Waldermort17-Dec-06 18:55
Waldermort17-Dec-06 18:55 
AnswerRe: assembly Pin
Mohammad A Gdeisat17-Dec-06 22:22
Mohammad A Gdeisat17-Dec-06 22:22 
QuestionRichedit text box Pin
zareee17-Dec-06 18:32
zareee17-Dec-06 18:32 
AnswerRe: Richedit text box Pin
prasad_som17-Dec-06 18:37
prasad_som17-Dec-06 18:37 
GeneralRe: Richedit text box Pin
zareee17-Dec-06 19:10
zareee17-Dec-06 19:10 
QuestionAbout CD/DVD Writing Software Pin
yudhisthira17-Dec-06 17:53
yudhisthira17-Dec-06 17:53 
AnswerRe: About CD/DVD Writing Software Pin
kakan17-Dec-06 19:29
professionalkakan17-Dec-06 19:29 

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.