|
zenzero wrote: LPCTSTR lpFilename = static_cast(Marshal::StringToHGlobalAnsi(filename).ToPointer());
IF you build this with unicode support this won't work as LPCTSTR will point to wide string but StringToHGlobalAnsi return's an ANSI string. If you want unicode string then use StringToHGlobalUni and if you want to build using both ANSI and UNICODE then use StringToHGlobalAuto.
-Saurabh
|
|
|
|
|
Thank you so much.
It's amazing how such a little thing can cause so much trouble!
Regards,
zenzero
|
|
|
|
|
Hi,
I have an ActiveX control and i am using it in my managed C++. What happens is when ever i am compiling my client application i need to crete interops by using Aximp exe and manually copy it to my bin directory is there any way to automate this like post build script. Like when ever i'm compiling my client application interops need to created automatiocally and that sould be copied in the bin directory.
|
|
|
|
|
You can wrap this in a script and set it to be run as a post-build event.
To do that, check out Project->Properties->configuration Properties->Build Events->Pre-Post-Build Event
gmileka
|
|
|
|
|
CString *str = ASCIIEncoding::GetString (resultArray);
I am working in VC++.Net; when i was trying to use the above statement to convert the unsigned character array to string i am getting
error C2352: 'System::Text::ASCIIEncoding::GetString' : illegal call of non-static member function
How to resolve this.
|
|
|
|
|
Create an instance of ASCIIEncoding and then use GetString from that object.
|
|
|
|
|
|
In recent days I have been investigating SSPI for a C# .NET remoting app that I have do for work. I came across the Microsoft sample SSPI dll which written in C++.
Has anyone sucessfully built it using Visual Studio 2005? If so how? I keep getting a build error and can't find any reference on how to fix it either by casting or using a different API. It does build with VS 2003.
The error is as follows
error C2440: '=' : cannot convert from '__const_Char_ptr' to 'wchar_t __pin *'
in
pwszServerPrincipalName = PtrToStringChars(serverPrincipalName);
where:
wchar_t __pin* pwszServerPrincipalName = NULL;
and
serverPrincipalName is a String * passed into the ClientContext(...) method.
Otherwise if someone could point me in the right direction I would be most grateful. I need to perform a simple authentication of the client which includes licence check, hence the need for custom authentication.
Thanking you advance.
Happy programming!!
|
|
|
|
|
Isn't always the way? You ask a question because you're at a loss at what to do and within the hour or so you are made to feel real small cause you find the answer.. "why didn't I look in that place in the first instance you think."
Anyway the answer is here
http://support.microsoft.com/default.aspx?scid=kb;EN-US;311259
Happy programming!!
|
|
|
|
|
Hi,
I'm going to start learning C++/CLI after the next 2 weeks. As a beginner thought to myself I need to be fammilier with COM before starting . But learning COM will take a long time (I think).
Could some one guide me please:
Is it better to learn (basic) COM before .Net CLI, or there is no need?
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|
|
Depending on your goal of learning C++/CLI.
You can think of C++/CLI as a language/technology just like C# - which means you don't have to learn COM to be able to write meaningful applications.
However, in many cases, the reason people learn C++/CLI is to cross between the native and managed worlds... So, this means that the user need to understand their native code base and what technologies it is relying on to make the decision on what to learn...
So, I think you won't 'have to' to learn COM unless you have some native C++ code that relies on COM... And for most native applications this is the case...
The "Pro Visual C++/CLI and the .NET 2.0 Platform" book by Fraser and published by Apress is a good start...
gmileka
|
|
|
|
|
Thanks alot.
So, I think it's better to start with CLI now and forget COM unless it was needed.
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|
|
|
Hi Nishant and thanks.
I already read 'A first look at C++/CLI' (forgot to vote then) and gave a 5 now (after 2 years!)
As a newbie I should say your articles are great alone, but together, well I need a more essential starter! Some thing to start with .net basics and it's usages for a c++ developers, benefits and how to impelements, all together. I think I need to read a book.
And, It's funny, you wrote most of the articles in C++/CLI. Author Nishant Sivakumar and I'm still scrolling ...
//This is not a signature
while (I'm_alive) {
printf("I Love Programming");
}
|
|
|
|
|
Hamed Mosavi wrote: well I need a more essential starter!
I am writing a book on C++/CLI now for Manning Publications. See my sig for more info. It'll be another 4 months before the book will become available though.
Regards,
Nish
|
|
|
|
|
|
Hamed Mosavi wrote: However I'll probably can't buy that:
Don't you have banks in Iran that issue credit cards? Even in India, we've had them for decades now.
Regards,
Nish
|
|
|
|
|
Hamed Mosavi wrote: From your signature, I found that out already and added a comment there;)
Yep, saw that.
Regards,
Nish
|
|
|
|
|
I have a .NET Control which I want to host in a CDialog. It's quite easy by including afxwinforms.h and having a member variable like this:
CWinFormsControl<mycontrol::controlclass> m_myControl
But the problem is that if I do something like this I have to include afxwinforms.h in my header file. I am including this header file in other classes and I dont want to enable clr for those classes.
Is there any workaround to this. I have tried something like having a CWnd* as a member variable and casting it to CWinFormsControl in .cpp but type-casting for CWinFormsControl doesnt work.
<font color="blue" size="1">
"Writing specifications is like writing a novel. Writing code is like writing poetry."
</font>
</mycontrol::controlclass>
|
|
|
|
|
Aamir Butt wrote: I have a .NET Control which I want to host in a CDialog. It's quite easy by including afxwinforms.h and having a member variable like this:
CWinFormsControl<mycontrol::controlclass> m_myControl
But the problem is that if I do something like this I have to include afxwinforms.h in my header file. I am including this header file in other classes and I dont want to enable clr for those classes.
Is there any workaround to this. I have tried something like having a CWnd* as a member variable and casting it to CWinFormsControl in .cpp but type-casting for CWinFormsControl doesnt work.
You could try a #ifdef _MANAGED block to declare the CWinFormsControl member.
Regards,
Nish
|
|
|
|
|
Wouldn't that change the class layout depending on who's including it?
For example, if I include the header in a .cpp that is compiled native, the class layout does not contain the managed memeber.
If I include the header in a .cpp that is compiled /clr, the class layout contains the managed memeber...
This means they are essentially two different classes with the same name...
The linker should emit an error in that scenario and not allow it... I haven't tried it though, so I might be wrong.
gmileka
|
|
|
|
|
georgeraafat wrote: Wouldn't that change the class layout depending on who's including it?
Yes, it would. A workaround would be to use a CWinFormsControl* member if it's managed compilation, and a dummy void* if it's unmanaged compilation. Thus the class layout is unchanged.
Regards,
Nish
|
|
|
|
|
Yes, this one looks good. Let me try it and then I will let you know if it works or not. Thanks for the reply.
"Writing specifications is like writing a novel. Writing code is like writing poetry."
|
|
|
|
|
Hi,
I couldnt use System namespace inside the MFC ActiveX control page. It says name space with this name doesnt exist. What should i do to use all the class like Convert etc...
|
|
|
|
|
sivaprakashshanmugam wrote: Hi,
I couldnt use System namespace inside the MFC ActiveX control page. It says name space with this name doesnt exist. What should i do to use all the class like Convert etc...
Please ask this in the Visual C++ forum. Sorry my bad! Didn't read your post properly.
To use the namespace and its classes, you need a reference to the containing assembly.
Regards,
Nish
Last modified: Thursday, May 25, 2006 2:32:19 PM --
|
|
|
|