|
You mean something like GetUserName() ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
<br />
char c = 0xA0;<br />
<br />
if(c == -96)<br />
{<br />
cout << "why does c==-96 but not equals 160?" << endl;<br />
}<br />
|
|
|
|
|
A char is a signed byte. Which means it goes from -127 to +127, with the first bit being the sign bit.
|
|
|
|
|
When a char is a signed 8 bit integer then (char)160 (10100000) is equal to (char)-96 (10100000)
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
so, to finalize the others' answers, if you want to see 160, either declare c as being an unsigned char or cast it into an unsigned char when testing it.
|
|
|
|
|
hanlei0000000009 wrote: "why does c==-96 but not equals 160?"
because -96 and 160 are quite different numbers.
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.
[my articles]
|
|
|
|
|
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
ROTFLMAO
Maxwell Chen
|
|
|
|
|
Hi,
i'm trying to pass a LPCSTR from a C++ Dll to a VB Code.
I'm getting no Error Message but the String will not appear in the Msg Box of the VB code ! I'm really drivin Crazy with this.
Here are some lines of the code:
VB
<br />
Option Explicit<br />
<br />
Private Declare Function fnWin32DLL02 Lib "Win32DLL02.dll" () As Integer<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 = "abc";<br />
<br />
return s;<br />
}<br />
Many Thx for your answers,
Best Regards
Croc
|
|
|
|
|
Strings in VB are a little more involved underneath than strings in C++. Try changing the Dll end to return a BSTR allocated with SysAllocString or a related API. If BSTRs (BeeStings ) just seem way to awkward ATL provides the very useful CComBSTR class which deals with many of the painful bits for you. BSTRs have the length written into 2 bytes on the front of the string followed by the string which may or may not be NULL or even double NULL terminated.
This is what VB does for you when you use it's friendly string type.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Matthew Faithfull wrote: BeeStings
Beasters!
|
|
|
|
|
Matthew Faithfull wrote: BSTRs (BeeStings
Bastard ...
Maxwell Chen
|
|
|
|
|
AFAIK you also have to use __stdcall calling convention.
Does your WIN32DLL02_API already contain it?
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.
[my articles]
|
|
|
|
|
Hi Pallini,
jap you are right __stdcall is in WIN32DLL02_API but i could not manage this, is it possible for you to insert the lines in the code ?
I know that is not a "rent a coder", but i have the worst prob with this Dll since ... !!!
When I use This Code I get an "a" not "abc" and i culd not pass a Strin parameter to the function fnWin32Dll02(void), when I try it(shure with a LPCSTR or a BSTR param. in the function interface) i get an Error, pleeeese help me it's horror !
<br />
WIN32DLL02_API BSTR fnWin32DLL02(void)<br />
{<br />
<br />
BSTR s;<br />
<br />
s = SysAllocString(L"abc");<br />
<br />
return s;<br />
}<br />
<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 />
<br />
Private Sub Form_Load()<br />
<br />
Dim x As String<br />
<br />
x = Space$(6)<br />
x = fnWin32DLL02()<br />
MsgBox "X ist: " & x<br />
<br />
End Sub<br />
<br />
Many thx hopefully and best regards
Croc
|
|
|
|
|
I'm a tenacious guy... Eventually I was able to make some test using VB and VC++6.
The code:
DLL header
#ifdef DLLSIMPLE_EXPORTS
#define DLLSIMPLE_API __declspec(dllexport)
#else
#define DLLSIMPLE_API __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C"
{
#endif
DLLSIMPLE_API BSTR __stdcall fnHello(void);
#ifdef __cplusplus
}
#endif
DLL source (.cpp )
#include "stdafx.h"
#include "oleauto.h"
#include "DLLSimple.h"
DLLSIMPLE_API BSTR __stdcall fnHello(void)
{
LPCSTR pChar = "hello VB!";
BSTR bstr = SysAllocStringByteLen(pChar, strlen(pChar));
return bstr;
}
VB source
Private Declare Function fnHello Lib "DLLSimple.dll" Alias "_fnHello@0" () As String
Private Sub Form_Load()
Dim s As String
s = fnHello
MsgBox s
End Sub
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.
[my articles]
|
|
|
|
|
What I usually do in these cases is 'force' my VB brethren to use strings and counters.
<br />
<br />
Public Declare Function fnWin32DLL02 lib "whatever.DLL" ( ByRef SomeString as String, ByVal SomeLength as Long ) As Long<br />
<br />
Dim x As String<br />
DIM y As Long<br />
Dim z As Long<br />
<br />
x = Space$(3)<br />
y = 3<br />
z = fnWin32DLL02(x,y)<br />
Then the C interface becomes
<br />
long __stdcall fnWin32DLL02(char** pbuffer, long nBufferCount)<br />
Just make sure you space fill the buffer up to nBufferCount.
|
|
|
|
|
Thx Pallini and Chis,
it works, but i had to change the ByRef to Byval Chris !
Thx a lot
Croc
|
|
|
|
|
Hi all,
I would like to know whether there is a way that one can keep a table in memory, so that there is no need to read from a db table.
Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
|
thanks for the response I'll have a look
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
isn't what a CResultset made for ?
by the way, keep in mind that your database datas may be modified by another process (i consider the common case when the DB is remote, with several clients querying on it). so if one client stores its query result, without ever refreshing them by times, you may have not synchronized data.
|
|
|
|
|
toxcct wrote: isn't what a CResultset made for ?
DataTables are made for. (Un)fortunately they belongs to the managed realm.
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.
[my articles]
|
|
|
|
|
I have 3 combo boxes in my application. and this 3 combo boxws indicate opening a folder and logging the data. the existing system is like whenever the appliaction is opened, it starts loggin in the data. i dont want to do that. now what i want to do is when i check one of the check box it should start loggin in in one folder and it has to be done during runtime. what can be done for this?
|
|
|
|
|
And what is the problem, aren't you able to handle check boxes events?
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.
[my articles]
|
|
|
|
|
i am sorry for not completing the query. i am initiating a socket. when i enable the socket a message gets passed to a folder. this is already there in the application. now i need to log this message whenever i need. for this i am using a check box. if i click the check box the message should get logged in. if i dont check the check box the message should not get logged in. and i should be able to do this when the socket is on. i need to know how can it be done. i hope the problem is clear now.
|
|
|
|