Click here to Skip to main content
16,004,977 members
Home / Discussions / COM
   

COM

 
AnswerRe: How do I change the program id within the com project Pin
Steve S19-Nov-03 5:44
Steve S19-Nov-03 5:44 
QuestionSame method and property name? Pin
snappa19-Nov-03 2:29
snappa19-Nov-03 2:29 
AnswerRe: Same method and property name? Pin
Vi221-Nov-03 2:31
Vi221-Nov-03 2:31 
GeneralMessages in ActiveX components Pin
Anonymous18-Nov-03 10:06
Anonymous18-Nov-03 10:06 
GeneralRe: Messages in ActiveX components Pin
Anonymous18-Nov-03 10:32
Anonymous18-Nov-03 10:32 
GeneralCOM instances Pin
Chiew Heng Wah17-Nov-03 19:08
Chiew Heng Wah17-Nov-03 19:08 
GeneralRe: COM instances Pin
Giles20-Nov-03 9:55
Giles20-Nov-03 9:55 
Generalmore string trouble... Pin
rajdawg17-Nov-03 15:35
rajdawg17-Nov-03 15:35 
I know there have been numerous threads and articles regaring CString to BSTR conversion, but I can't seem to get the solutions given to work.
Here is what I have.
IN VB:
<br />
Private Declare Function GetNextCustomerID Lib "C:\Debug\DataAccess.dll" (CustomerID As String) As Long<br />

THEN:
<br />
Private Sub Form_Load()<br />
    Dim TestStr As String<br />
    Dim ret As Long<br />
    <br />
    ret = GetNextCustomerID(TestStr)<br />
    If ret = 1 Then<br />
        Label1.Caption = TestStr<br />
    End If<br />
End Sub<br />


THEN, IN C++
<br />
extern "C" long __stdcall GetNextCustomerID(BSTR& CustomerID)<br />
{<br />
	HRESULT hr = CoInitialize(0);<br />
	long ret = 0;<br />
        CString tmp;<br />
<br />
	if(SUCCEEDED(hr))<br />
	{<br />
		dbReferenceNums dbR; //<<==CRecordset class that connects to DB.<br />
		if(dbR.Open())<br />
		{<br />
			if(!dbR.IsEOF())<br />
			{<br />
				tmp.Format("%s%d", "CX",  dbR.m_NextAvailCustID);<br />
				CustomerID = tmp.AllocSysString();<br />
				ret = 1;<br />
			}<br />
			dbR.Close();<br />
		}<br />
		CoUninitialize();<br />
	}<br />
	return ret;<br />
}<br />


if the string is "CX1504", then the result that is printed in VB is "C" and that is all. I assume it is because a null character is encountered, because there is a null character between each character of the string. But, I can't figure out how to prevent this. I thought BSTRs were WCHAR-based strings and this behavior (nulls between each char) would be expected, but it is not interpretted correctly by VB.

Thanks in advance for any help you can provide.
raj.
GeneralRe: more string trouble... Pin
Vi218-Nov-03 0:39
Vi218-Nov-03 0:39 
GeneralRe: more string trouble... Pin
Mike Dimmick20-Nov-03 2:08
Mike Dimmick20-Nov-03 2:08 
GeneralRe: more string trouble... Pin
rajdawg20-Nov-03 13:41
rajdawg20-Nov-03 13:41 
GeneralDatabase communication Pin
Moonspellwizard17-Nov-03 0:03
Moonspellwizard17-Nov-03 0:03 
GeneralRe: Database communication Pin
Ivor S. Sargoytchev22-Nov-03 7:54
Ivor S. Sargoytchev22-Nov-03 7:54 
GeneralUpgrading a COM interface Pin
Jeremy Pullicino16-Nov-03 21:13
Jeremy Pullicino16-Nov-03 21:13 
GeneralRe: Upgrading a COM interface Pin
Abhishek Srivastava16-Nov-03 22:01
Abhishek Srivastava16-Nov-03 22:01 
GeneralRe: Upgrading a COM interface Pin
Steve S16-Nov-03 23:12
Steve S16-Nov-03 23:12 
GeneralDirectShow (DirectX) Pin
TFB15-Nov-03 7:38
TFB15-Nov-03 7:38 
GeneralRe: DirectShow (DirectX) Pin
Chiew Heng Wah17-Nov-03 19:17
Chiew Heng Wah17-Nov-03 19:17 
GeneralRe: DirectShow (DirectX) Pin
TFB18-Nov-03 6:34
TFB18-Nov-03 6:34 
Generalmessage box Pin
Ritwik Sanyal14-Nov-03 21:03
Ritwik Sanyal14-Nov-03 21:03 
GeneralCasting IXMLDocument to VARIANT Pin
bariraniahmad14-Nov-03 11:19
bariraniahmad14-Nov-03 11:19 
GeneralPassing ADODB.Stream from ASP to C++ Pin
Jeremy Pullicino14-Nov-03 3:56
Jeremy Pullicino14-Nov-03 3:56 
GeneralClose AUTOMATION Process Pin
jerome_data12-Nov-03 23:35
jerome_data12-Nov-03 23:35 
GeneralRe: Close AUTOMATION Process Pin
FearlessBurner14-Nov-03 2:16
FearlessBurner14-Nov-03 2:16 
GeneralCoUninitialize causes access violation Pin
sagmam12-Nov-03 2:53
sagmam12-Nov-03 2:53 

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.