Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

VB's String tip u VC++ ?

[es] :: C/C++ programiranje :: VB's String tip u VC++ ?

[ Pregleda: 1780 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Burgos
Nemanja Borić
Amazon Web Services
Berlin

Član broj: 12484
Poruke: 1947
195.252.80.*

Sajt: stackoverflow.com/users/1..


+480 Profil

icon VB's String tip u VC++ ?04.03.2005. u 17:51 - pre 233 meseci
Počeo sam da pravim dll u VC++.
Evo kod koji radi:
Code:

extern "C" __declspec(dllexport)

int NumberList () {
     return 158;
 }


Kada pozovem funkciju u VBu sve je OK (ispiše mi 158):

Code:
Private Declare Function NumberList Lib "ddll.dll" () As Integer
      
Private Sub Form_Load()
    MsgBox NumberList
End Sub


Problem (u stvari pitanje):
Kako da mi funkcija vrati string tip. Probao sam sa:

Code:
LPCSTR NumberList () {
     return "Funckija";
 }


ali u VBu promenljiva tipa string je prazna, tj. uopšte ne prihvata vrednost funkcije.

Postoji li neki tip promenljive koji je ekvivalentan String tipu u VBu?
 
Odgovor na temu

Burgos
Nemanja Borić
Amazon Web Services
Berlin

Član broj: 12484
Poruke: 1947
195.252.80.*

Sajt: stackoverflow.com/users/1..


+480 Profil

icon Re: VB's String tip u VC++ ?04.03.2005. u 18:00 - pre 233 meseci
Nema veze, rešio sam sam:

Citat:
In Visual Basic, strings are stored in the same way as the C++ BSTR type.

Citat:

Unlike most data types, strings must be handled in a special manner in C++, especially when they are returned from a function. In order to return a string, a system function must be called to properly allocate memory for it. Otherwise, the string will disappear when the function terminates and the client will receive garbage.


Znači:

Code:
#include <windows.h> //potrebno za BSTR

extern "C" __declspec(dllexport)


BSTR NumberList () {

     return SysAllocString((BSTR) "FUNCTION");

 }


http://www.flipcode.com/articles/article_vbdlls.shtml
 
Odgovor na temu

[es] :: C/C++ programiranje :: VB's String tip u VC++ ?

[ Pregleda: 1780 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.