|
Nemanja Trifunovic wrote: You can use BSTR only if you have a COM dll, which you obviously don't. So, try returning good ol char* instead.
Are you sure? If I remember it right, I've returned BSTR from a regular dll for some reason and I think it worked. I am not on my Dev machine now to verify it.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: I've returned BSTR from a regular dll for some reason and I think it worked.
IIRC, it is "doable" if you catch it as a byte array on the VB side, but it does not work out of the box.
|
|
|
|
|
In addition to what the other posts said, you are also misusing casts.
(BSTR)"abcde" is wrong - a string literal is not a BSTR .
(LPCSTR)s is wrong - a BSTR is not a const char* .
Casts are not the right way to solve compiler errors. Check out The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^] so you get an understaning of string encodings.
|
|
|
|
|
BSTR[^]
typedef WCHAR OLECHAR;
typedef OLECHAR FAR * BSTR;
WCHAR[^]
#if !defined(_NATIVE_WCHAR_T_DEFINED)
typedef unsigned short WCHAR;
#else
typedef wchar_t WCHAR;
#endif
Maxwell Chen
|
|
|
|
|
Firs of all,
*THX* to all of you for your answers,
i tried it all ways but it still wont work, i could not find the mistake, i really don't know what i coud do !
These are my latest Codes:
VB:
<br />
Option Explicit<br />
<br />
Private Declare Function fnWin32DLL02 Lib "E:\WORKING\OMRON\GDT\EigeneDLL\Übergabe eines Strings aus C++ Dll\Win32DLL02.dll" () As String<br />
<br />
Private Sub Form_Load()<br />
<br />
Dim x As String<br />
<br />
x = Space$(3)<br />
x = fnWin32DLL02()<br />
MsgBox "X ist: " & x<br />
<br />
End Sub<br />
Cpp:
<br />
WIN32DLL02_API LPCSTR fnWin32DLL02(void)<br />
{<br />
LPCSTR s;<br />
s = "abc";<br />
return s;<br />
}<br />
Many thanx again
Croc
|
|
|
|
|
When using a Declare statement, Visual Basic converts strings (which it stores internally as Unicode UTF-16) to ANSI, using the default code page. There is no way to control which code page is used.
Your C++ DLL should therefore be ANSI throughout, i.e. using char* and derived types (e.g. LPSTR, LPCSTR).
On return from the function, ByRef parameters are converted back to Unicode as appropriate.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Hi everyone
Can you give give me a good tutorial about make device driver of course maybe you will be say that codeproject has articles about make it or if you use of google you can find a lot info about it but I want to start of first,what is device driver and then start to writing code?
Thanks
|
|
|
|
|
1) You have to install WDK (Windows Driver Kit) to compile the source code. Visual Studio (Visual C++) is not able to make device drivers (unless you install some third-party add-on to Visual C++).
2) Different type of device drivers require different callback functions. For example, a card reader driver has different callbacks from what a SCSI miniport driver has.
Maxwell Chen
|
|
|
|
|
Can you give me abour device driver what is it and I have VS2005 does it perfect for make it?
Thanks
|
|
|
|
|
messages wrote: abour device driver what is it
A device driver is to control a hardware device.
messages wrote: I have VS2005 does it perfect for make it?
No, VS2005 is useless to make a device driver. (But is good to view source code.)
You have to get a copy of WDK and install it. It will brought you some shortcuts to open DOS-box command-line environments for you to compile the source code.
Windows Driver Kit Homepage[^]
Maxwell Chen
|
|
|
|
|
|
Last year I can find some articles which is written for beginners. After upgrade those articles are missing. Who can tell me how to find them?
There is a will,there is a way!
|
|
|
|
|
What article or articles you need to see?
|
|
|
|
|
I downloaded a sample program in codeproject.com last year. I can’t find the article along with it.The demo project is named “TreePropSheetDemo”. Can you help me find it or tell me how to find it?
There is a will,there is a way!
|
|
|
|
|
(Sorry my system is having problem pasting URLs.)
Tree property sheet
http://www.codeproject.com/KB/tabs/treepropsheet.aspx
Tree property sheet Ex
http://www.codeproject.com/KB/tabs/treepropsheetex.aspx
Maxwell Chen
|
|
|
|
|
Thanks a lot!
There is a will,there is a way!
|
|
|
|
|
I have on Claas that whitin one of the methods/function references
a public method/function of another Class
Does referenced class method have to be static
Truth is I want only one instance of the Referenced Class
I guess its not possible to use the static attribute before the Class Keyword
The only to make The Entire Class Static is to make every member/fuction static
|
|
|
|
|
Do you mean this?
class Object
{
public:
Object() { }
type Test() { }
};
static Object obj;
#include "some.h"
extern static Object obj;
class Invoker
{
public:
type UseStaticObj() { return ::obj.Test(); }
};
Maxwell Chen
|
|
|
|
|
I understand the only way to implement the Class as static is When actually declare it as a Object
I was getting compile errors when I was writting the code for the Class
Referencing a Method Class b from a e.g.
CLass A
{
private:
int c;
char d;
public:
int e()
{
return c;
}
}
Class b
{
private:
public:
int f;
f = getc() // compile error because the compiler wouldn't
{ // know what instance of e I want unless I declare it
e(); // static right ????
}
}
|
|
|
|
|
Fornow I dont understand the question completely, but fornow I can say you something.
First be clear on your design.
You want the referenced class to be single instanced all across the world?
If so , it has to be a singleton.
Or, if you just want the referenced class to be single instanced with the referencing class. It can simply be a static object inside the referencing class.
Note: To use it as a static object, you dont need to use "static" key with the referenced class. Grrrr. It just needs to be prefixed with the object in the referencing class.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Hope this code better explains what my I am trying to do
CLass A
{
private:
int c;
char d;
public:
int e()
{
return c;
}
}
Class b
{
private:
public:
int f;
f = getc() // compile error because the compiler wouldn't
{ // know what instance of e I want unless I declare it
e(); // static right ????
}
}
|
|
|
|
|
Hey!! What are you trying to do??
Class b
{
private:
public:
int f;
f = getc() // compile error because the compiler wouldn't
{ // know what instance of e I want unless I declare it
e(); // static right ????
}
}
f = getc();
e();
And finally, take a good c++ book it's all there in the third page.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Thank you
I understand as you can tell I Am just starting to code in OO
|
|
|
|
|
ok no probs! But what I suggested was that you should start from basics then look at complex stuff otherwise you'll waste a lot of time getting puzzled.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
I think I am begining to understand
A class is really a typedef not real storage only when you declare that object then storage is allocated
If you have a object you want to modify e,g, add you derive that Class
you can access private data members in the derived class by writting your own constructer for it
When you derive it as you stated and use a function/data from derived object the compiler is not confused which instance it the this-> instance
I think I have a better understanding
|
|
|
|