|
Hi,
I've made a dll for use within a PowerBuilder application. When I compile this dll under Windows Xp it runs well under Windows Xp and Windows 2000. On Windows NT however, it crashes. The problem is due to the fact that, when compiled under Xp the size of the MENUITEMSTRUCT I use is set to 48 while it's 44 on NT. How can I change the coding so it runs on both Xp and NT.
This is the code I use for setting the size:
MENUITEMINFO info
info.cbSize = sizeof MENUITEMINFO;
Thanks in advance,
Aart
|
|
|
|
|
As long as _WIN32_WINNT is defined to be less than 0x0500, you should be all right.
The hbmpItem member should only be included if _WIN32_WINNT is greater than or equal to 0x0500 (i.e. if you're targetting Windows 2000 or later).
|
|
|
|
|
Im writing a program that searches an ActiveDirectory database and want the program to take a search argument like "moderator" through a dialog window and the program will search for everyone that is a moderator.
So my search function takes a CString as a parameter
But to use it in the search it must be a LPWSTR (pszSearchFilter).
HRESULT ExecuteSearch(LPWSTR pszSearchFilter, LPWSTR* pAttributeNames, DWORD dwNumberAttributes, PADS_SEARCH_HANDLE phSearchHandle);
I havetried to builda CString that looks like this:
L"(&(objectClass=user)(title=moderator))";
And then it must be converted to LPWSTR or CComBSTR or whatever that works ... any ideas how ?
Thanks in advance !
|
|
|
|
|
Try converting the CString into a _bstr_t
CString searchParameter("the search string");
_bstr_t bstr(searchParameter);
Mike
|
|
|
|
|
You should be able to do it like this...
CString str("Hack on!");
BSTR bstr = str.AllocSysString();
CComBSTR bstrTemp;
bstrTemp.Attach(bstr); Hack on...
Jonathan Craig
www.mcw-tech.com
|
|
|
|
|
Thanks guys, got it to work thanks to your tips !
|
|
|
|
|
I have a application developed in MDI.
The strange thing is that it will cause my system utilizing 100% of the CPU usage.
I have checked the OnIdle(), OnTimer and OnUpdateCommandUI but it is not the cause of the problem
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
You will need to trim the code down to the minimum required to reproduce the problem. Or, you can create a new MDI application and add code to it until the problem appears.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Please help me. i am a MFC beginner , and i don't know how to combine two numbers in a dialog box. for example: when a and b are entered into Box1 and Box2, In Box3 will show "ab", NOT "a+b" . Please........HELP.
|
|
|
|
|
using CString + operator
Eg.
CString str = atoi(YourInteger);
str += "2";
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
using CString + operator
Eg.
CString str = atoi(YourInteger);
str += "2";
Could u explain more on these?
I am not able to follow it.
|
|
|
|
|
hey, guy, try this...
...
char szA[100], szB[100], szC[200];
int c;
printf(szA,"%d",a); //here, a is a int number entered on edit box 1.
printf(szB,"%d",b); //here, b is a int number entered on edit box 2.
strcpy(szC,szA);
strcat(szC,szB);
c = atoi(szC); //here, c is the int number you want, just place it into edit box 3
...
hope this helps!
|
|
|
|
|
char szA[100], szB[100], szC[200];
int c;
printf(szA,"%d",a); //here, a is a int number entered on edit box 1.
printf(szB,"%d",b); //here, b is a int number entered on edit box 2.
strcpy(szC,szA);
strcat(szC,szB);
c = atoi(szC); //here, c is the int number you want, just place it into edit box 3
This doesn't work for me.
What is char szA[100], szB[100], szC[200];?
Should I use Cstring for BOX3?
|
|
|
|
|
How "it doesn't work for you"? what error occurred?
szA,szB,szC just are temporary char string variables.
|
|
|
|
|
No error occurred, but nothing appear in box3
|
|
|
|
|
oh, god...
just attach a CString class variable with your edit box 3, and then make it equal to "szC", and then call UpdateData(FALSE) to make it show in edit box 3...
|
|
|
|
|
and, you can also...
attach a int variable with your edit box 3, and then make it equal to c, and then call UpdateData(FALSE) to make it show in edit box 3...
|
|
|
|
|
Anonymous wrote:
What is char szA[100], szB[100], szC[200];?
I think you need to find yourself a good beginner's C++ book
if you need to ask that question. Never mind string concatenation, read up about variable declaration first.
Let us walk before we run.
I Dream of Absolute Zero
|
|
|
|
|
Grab some tutorials on CDialog in codeproject.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
CString cstrMyNumbers(_T(""));
cstrMyNumbers.Format(TEXT("%d%d"), a, b);
Simple as that
Regards,
Michael Mogensen, mm it-consult dk.
><((((º> ·.¸¸.· ><((((º> ·.¸¸.· ><((((º>
|
|
|
|
|
Hi… there,
I wonder how you guys deal with the case of more than one available IP address (multi-IP) on the local host on the TCP/IP programming mode.
I'm talking about the "multi-IP" here, it's usually the system which installed with more than one network adapter (physical or virtual), i.e., more than one available IP address…
In the case, when you call the socket API "bind" to bind your socket with the local host, you must choose the proper IP address from the multiple IP addresses, otherwise, your socket possibly cannot work.
So, my problem is: how do you know which IP address is available on that LAN? The current solution I'm using is: Present a dialog with a list control, and all the available local IP addresses listed on the list control, then ask the user select the proper one that my program would use...
Does anyone here can tell another better solution to this problem? i.e., how does my program automatically detect all the IP addresses, then automatically pick up the proper one, instead of asking the user for this?
Thanks!
|
|
|
|
|
What do you mean by the 'proper one'. Usually it is sufficient to use ADDR_ANY. This allows you to listen on all local address.
From MSDN docs for bind() :
If an application does not care what local address is assigned, specify the manifest constant value ADDR_ANY for the sa_data member of the name parameter. This allows the underlying service provider to use any appropriate network address, potentially simplifying application programming in the presence of multihomed hosts (that is, hosts that have more than one network interface and address).
...cmk
Rosencrantz: I don't believe in it anyway.
Guildenstern: What
Rosencrantz: England
Guildenstern: Just a conspiracy of cartographers then.
Save the whales - collect the whole set
|
|
|
|
|
cmk wrote:
...This allows you to listen on all local address...
Well, if you just "listen" and not "send" data,or the local host has ONLY one IP address, it would be fine. But by this way, if the local host has more than one IP address and you want to send data to the other host, it may not work sometimes, why? because "the underlying service provider" sometimes would automatically bind an "exist-but-not-connect" IP (though a host have several IP addresses, maybe only one or some connectable and others don't), and, of course, you cannot send data outside successfully via it... and this is approved in my current application
What I mean "proper one" is: you cannot alway hope that the ADDR_ANY would do the right thing for you, you must find out the working and connectable IP address, and then bind your socket to it.
Thank you!
|
|
|
|
|
Ok, so the only case you are looking at is creating a socket to use as a client that you can use send() on.
Although i haven't tried it, you may want to try creating the socket, don't bind it, and then use sento() as the first send, as this performs an implicit bind on the socket. After that you should be able to use send(). I would assume that the implicit bind() would bind to an address that allows a connection to the specified node/port i.e. is 'live'.
...cmk
Rosencrantz: I don't believe in it anyway.
Guildenstern: What
Rosencrantz: England
Guildenstern: Just a conspiracy of cartographers then.
Save the whales - collect the whole set
|
|
|
|
|
I haven't tried this myself: you can probably use the gethostbyname function to return a HOSTENT structure, the returned structure contains a list of null terminated ip addresses.
Good luck.
My articles and software tools
|
|
|
|
|