|
Hi Mark/Micheal,
Thanks for the response.
I'm still having problem in using the macro USES_CONVERSION.
I'm not using ATL in my project.
Could you let me know an alternative solution with VC++6.0 / MFC?
thanks in advance,
Rajesh
|
|
|
|
|
Hi Rajesh,
Michael's solution should work for VC++ 6. It will NOT work on VC++ 8, so you may want to keep
that in mind if you ever plan to migrate to a new version of C++.
*EDIT* Actually, it WILL work, but you'll need to add the USES_CONVERSION macro in VC++ 8.
Sorry for my confusion
Mark
Last modified: 1hr 10mins after originally posted --
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I found the code on [http://www.wincli.com/?p=72].
These two functions is what you need:
<br />
int wstrlen(_TCHAR * wstr)<br />
{<br />
int l_idx = 0;<br />
while (((char*)wstr)[l_idx]!=0) l_idx+=2;<br />
return l_idx;<br />
}<br />
<br />
char * wstrdup(_TCHAR * wSrc)<br />
{<br />
int l_idx=0;<br />
int l_len = wstrlen(wSrc);<br />
char * l_nstr = (char*)malloc(l_len);<br />
if (l_nstr) {<br />
do {<br />
l_nstr[l_idx] = (char)wSrc[l_idx];<br />
l_idx++;<br />
} while ((char)wSrc[l_idx]!=0);<br />
}<br />
nstr[l_idx] = 0;<br />
return l_nstr;<br />
}<br />
|
|
|
|
|
Hi, I'm a begginer in this programming stuff, and I learn visual C++ from the book "teach yourself visual c++ in 21 days". anyway I am on the 6th day now and I have a small problem with the menu code. here is the listing:
1.CMenu *m_lMenu;
2.CPoint m_pPoint;
3.m_pPoint = point;
4.ClientToScreen(&m_pPoint);
5.m_lMenu - GetMenu();
6.m_lMenu = m_lMenu->GetSubMenu(0);
7.m_lMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON, m_pPoint.x, m_pPoint.y, this, NULL);
now when I compile my project ( ofcourse there is other code which works just fine), compiler gives me 2 warnings:
D:\C\projects\menus\menusDlg.cpp(203) : warning C4552: '>>' : operator has no effect; expected operator with side-effect
D:\C\projects\menus\menusDlg.cpp(204) : warning C4700: local variable 'm_lMenu' used without having been initialized
this code is copied from the book so if there is error then the error is in th book.
So my question is what is the problem? my guess is that there is something wrong with line 5 (m_lMenu - GetMenu()) make's no sense right? or is the problem in something other?
I tried even with -> and .
|
|
|
|
|
|
Looks like line 5 should have used the = operator instead.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
This text is your translation from %LANGUAGE% into english?
Do you have a compiler error number (four digits with a 'C' or 'L' prefixed)?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Never mind - my own stupidity is the source of this "problem"
|
|
|
|
|
Vaclav_Sal wrote: Never mind - my own stupidity is the source of this "problem"
thats the wonderfull quote.....!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief
|
|
|
|
|
Since it is my original I am offering it to the public under
GNU GENERAL PUBLIC LICENSE.
Feel free to quote when you fail and are not embarrassed to admit it!
I am !!
|
|
|
|
|
Just because you have a solution to the problem, and it may be a little embarassing for you (we've all been there - including me just a few days ag0), please don't delete the question.
When people look at the forums, they'll just see answer's with no questions - and that's just confusing and rude.
Iain
|
|
|
|
|
Good comment, however there is no simple way to delete whole thread which in this case would be prefered.
My error was that I ovelooked my own error catching message and thread process was timing out on me. Thus I did not see the entry point.
I am not sure if that would be of any benefit to anybody.
|
|
|
|
|
Well, deleting the whole thread would be harsh on those people who kindly helped you - a little public visibility of helpers keeps them helping, I think.
I do understand where you're coming from though - I recently posted a dumb question, and kinda wished I could go back in time too....
Iain.
|
|
|
|
|
I have converted my exisiting vc6 project to vc8 i.e. visual studio 2005. Now i have created the exe and try to execute that on other pc where VS 2005 is not installed. I tried with linking MFC dlls statically even that is also not working.
Following error occurs when i execute the exe
"The application failed to initialize properly (0xc0150002). Click on OK to terminate the application."
Please help.
|
|
|
|
|
You are not trying to deploy a debug build, are you (or using any DLLs that are debug versions themselves)?
Just because you did a static MFC link does not mean that your application will not have any other DLL dependencies. Depends on what else you are using in your project.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Do you need this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for the help. Re-distributable component for 2005 worked
|
|
|
|
|
Ravi Jadhav wrote: Following error occurs when i execute the exe
"The application failed to initialize properly (0xc0150002). Click on OK to terminate the application."
actually execuatble compiled with VC8, are also using manifest file to execute. which doesn't present in new computers.. you just download and execute vcredist.exe (URL given by Mr. David Crow)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
hi all,
i am using VS2003 for VC++,
but if i create project of MFC, the default resource language is Chinese, so if i click on finish without changing the resource language, i have to delete the project and do all things again to change the resource language.
is there any way to set it to English as default?
thanx in advance!
|
|
|
|
|
So, I need to validate that a workstation exists on a local area network
I can do so in a few ways, like NetServerGetInfo or WNetGetResourceInformation
The annoying thing is, these functions hang for 30 seconds or so when passed
a workstation name that does not exist, example "\\notThere"
I thought of using some of the picg samples, but they require UDP protocol, which I cant depend on.
Does anyone know of a fast way to see if there is such a machine on the network?
Bill in PA/USA
|
|
|
|
|
Is IsDestinationReachable("\\\\notThere", NULL) of any help?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes that is better - about a 3 second wait for a non machine, versus about 30 seconds if GetFileAttributes() is called on a bad share.
Thanks for the tip.
Bill in PA/USA
|
|
|
|
|
Before anyone can provide an intelligent answer, do you need to know of a system (any system) is running at the IP address that the workstation name you provide resolves to, or do you need to make sure that a real Windows system is there?
If the former, something like a naive ping or routing tests will work. If the latter, you may be stuck with the functions you are using now. You could always throw up a "Please Wait" dialog while you are doing the test - like if you need to validate something against a license server...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
We find illegal copies of our software in several countries.
Currently we hope a new developped software can be installed only on buyer's computer. In other words, the software only can be installed on buyer's windows OS.
To do so, I need to get Unique Windows ID, and software is installed by checking the ID - my plan is: buyer sends the ID to us before we submit software to him.
I posted a post before which asks for Windows CD-key, but repliers said it is impossible.
Do u know any idea to get Unique Windows ID to help me?
thx.
|
|
|
|
|
includeh10 wrote: Do u know any idea to get Unique Windows ID to help me?
Several copy protection schemes resort to using the network adapters MAK.
I dont think you can get the windows code.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|