Click here to Skip to main content
15,913,685 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
Richard MacCutchan5-Feb-10 22:40
mveRichard MacCutchan5-Feb-10 22:40 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
MicroVirus8-Feb-10 0:31
MicroVirus8-Feb-10 0:31 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
Richard MacCutchan8-Feb-10 1:55
mveRichard MacCutchan8-Feb-10 1:55 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
Luc Pattyn4-Feb-10 12:56
sitebuilderLuc Pattyn4-Feb-10 12:56 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
Richard MacCutchan4-Feb-10 21:54
mveRichard MacCutchan4-Feb-10 21:54 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
Luc Pattyn4-Feb-10 23:32
sitebuilderLuc Pattyn4-Feb-10 23:32 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
Richard MacCutchan5-Feb-10 0:42
mveRichard MacCutchan5-Feb-10 0:42 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
TremaHD5-Feb-10 2:26
TremaHD5-Feb-10 2:26 
Hi guys,

After reading Luc's article (by the way, very interesting) and reading your posts, I tried to change the string type to Stringbuilder type. Because the C++ DLL sub has an OUT parameter, I modified the declaration to pass my variable byRef instead of ByVal:
 <DllImport("C:\Api.dll", EntryPoint:="?API_getApiVersion@@YAXPAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z", CallingConvention:=CallingConvention.ThisCall, CharSet:=CharSet.Unicode)> _
    Public Shared Sub test(ByRef version As StringBuilder)
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim theVersion As StringBuilder = New Stringbuilder(20)
        Call test(theVersion )
        MessageBox.Show(theVersion.tostring)
    End Sub
End Class

What is happening now is that when the line 'Call test(theVersion)' is executed, the application quit without any warning or error, even if I put a breakpoint at the 'Messagebox.show' line.Confused | :confused: Am I right to pass my variable byRef instead of byVal. Of course, I tried to change it to use byVal and what i get is an empty string in return.

When you look at the declaration line in the C++ code there is that #DECLARE API_SPEC line and that API_SPEC is also at the beginning of the method API_getApiVersion. Most of the time the DECLARE statement for __declspec(dllexport) use the C or C++ keyword to specify the language type. Here I have a keyword that is use at the beginning of the method definition. What is the purpose of that declare then?

Thanks again.
GeneralRe: Accessing DLL C++ with string pointer using VB.NET [modified] Pin
Luc Pattyn5-Feb-10 2:59
sitebuilderLuc Pattyn5-Feb-10 2:59 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
Richard MacCutchan5-Feb-10 4:10
mveRichard MacCutchan5-Feb-10 4:10 
GeneralRe: Accessing DLL C++ with string pointer using VB.NET Pin
TremaHD5-Feb-10 14:25
TremaHD5-Feb-10 14:25 
QuestionLocalization support for existing applications Pin
Md Saleem Navalur4-Feb-10 2:56
Md Saleem Navalur4-Feb-10 2:56 
AnswerRe: Localization support for existing applications Pin
R. Giskard Reventlov4-Feb-10 3:06
R. Giskard Reventlov4-Feb-10 3:06 
GeneralRe: Localization support for existing applications Pin
Md Saleem Navalur4-Feb-10 5:43
Md Saleem Navalur4-Feb-10 5:43 
AnswerRe: Localization support for existing applications Pin
Not Active4-Feb-10 6:50
mentorNot Active4-Feb-10 6:50 
QuestionBuilding a Compiler using Reflection.Emit Pin
PP19724-Feb-10 0:42
PP19724-Feb-10 0:42 
QuestionClipboard through COM Pin
Adriaan Davel3-Feb-10 21:37
Adriaan Davel3-Feb-10 21:37 
AnswerRe: Clipboard through COM Pin
Richard MacCutchan3-Feb-10 22:04
mveRichard MacCutchan3-Feb-10 22:04 
QuestionHow can an application create a remote GUI. [modified] Pin
User 592413-Feb-10 20:49
User 592413-Feb-10 20:49 
QuestionProblem with TCP socket in Windows service [modified] Pin
mavrick233-Feb-10 18:51
mavrick233-Feb-10 18:51 
AnswerRe: Problem with TCP socket in Windows service Pin
SeMartens3-Feb-10 21:25
SeMartens3-Feb-10 21:25 
GeneralRe: Problem with TCP socket in Windows service Pin
mavrick233-Feb-10 21:52
mavrick233-Feb-10 21:52 
GeneralRe: Problem with TCP socket in Windows service Pin
SeMartens3-Feb-10 22:01
SeMartens3-Feb-10 22:01 
GeneralRe: Problem with TCP socket in Windows service Pin
mavrick233-Feb-10 23:18
mavrick233-Feb-10 23:18 
GeneralRe: Problem with TCP socket in Windows service Pin
SeMartens4-Feb-10 1:46
SeMartens4-Feb-10 1: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.