|
Hi,
I have some problem compiling a managed C++ dll (a wrapper wround a unmanaged c++ dll).
It is very odd because it compiles fine on my laptop and desktop in the UK.
I am now In France for Xmas (merry Xmas to you guys by the way), I grabbed the code straight out from the source control (that is to say that it's exactly the same than what I compiled in the UK) and I get the following error:
error C2065 '_Ax': undeclared identifier from the vextor.h class!
from here exactly:
// TEMPLATE CLASS vector
template<class _Ty,
class _Ax>
class vector
: public _Vector_val<_Ty, _Ax>
Is there something missing zith my install on this machine?
It's using Vista and VS2008 SP1 Beta
Any help would be appreciated as I'm a bit baffled.
Cheers,
Regis
|
|
|
|
|
I don't think anyone could help you given that rather minimalist snippet you provided. Does the source include <vector> - Note that it is not vector.H anymore, stdlib file name conventions are followed since vs2005, the current declaration in C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector looks like:
template<class mode="hold" />
class _Ax = allocator<_Ty> >
class vector;
Perhaps you have an old copy of the vc6 vector.h that is in your include path, and the incorrect declaration
(#include <vector.h> instead of #include <vector>> ) is causing it to be incorrectly picked up? If you set configuration properties->C++->Advanced->show Includes to yes, the compiler output window will show a list of the include files actually used. this might help track down the prioblem.
|
|
|
|
|
hotbridge wrote: VS2008 SP1 Beta
Beta??
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've upgraded to SP1 and the problem is sorted.
Cheers
|
|
|
|
|
Hi, when I was programming in console mode if I needed to display only 2 decimal values of a variable (e.g. Variable1) I would write this simple code:
cout << "Variable1 = " << setprecision (2) << fixed << Variable1 << endl;
But now in C++/CLI environment how can I display this value inside a textbox showing only 2 decimal values?
Can I add some attributes to the following code?
textBox1->Text= Variable1.ToString();
And what about if I wanted to display it in Hexadecimal and/or in Upper case notation?
Many thanks in advance!
|
|
|
|
|
so you decided to use some type's ToString() method but you did not consider reading up about it?
|
|
|
|
|
Any advice please on where to find more info on this?
Thanks
|
|
|
|
|
Object.ToString() has several overloads. some accept formatting instructions and culture specifications. You can get help on MSDN (and in visual studio help). You should consult the ToString(0 documentation for the particular type you are concerned with, as the base class virtual methods are often overridden. The help for Int32[^] is typical, and should shed light on your question. There are many links to additional details on formatting in the help article.
|
|
|
|
|
In reply to my question...
textBox1->Text= Variable1.ToString("N0");
textBox1->Text= Variable1.ToString("N2");
textBox1->Text= Variable1.ToString("X");
textBox1->Text= Variable1.ToString("x");
Hope it helps somebody out there like me. I am really amazed there isn't a decent manual on these very basic things... It must all be there on MSDN but I find it the most impossible reference to consult.
|
|
|
|
|
|
Deal all,
I just want to know how can I convert an object to a user defined type pointer in managed C++. I will elaborate my situation. I want to use an ActiveX control in a windows form application written in C#. When we add an ActiveX into a project VS generates the RCW objects. In my case it is
private AxXVIDEOOCXLib.AxXVideoOCX axXVideoOCX1;
Now I will get the underlying ActiveX object using the function
Object obj = axXVideoOCX1.GetOcx();
Now I need to pass this object into a managed C++ dll(.net component). Inside this dll I have a function with prototype in an unmanaged class as follows
int CVideoRecorderCtrl::AddOCXHandle(CXVideoOCX* OCXHandle)
Can any one commment whether my approach is correct? If yes my question is yet to come.
The class CXVideoOCX is the class of ActiveX component. Is there any successful way so that I can convert this COM object to its actual unmanaged type..I am searching for a solution for past 1 week. I will be really really thankful if anyone have any comments on these.
|
|
|
|
|
I was wondering if anybody could give me hand solving this problem. I need to save a DWORD value (DesiredValue) in a registry key and this was the syntax I was using (successfully) in console environment.
DWORD DesiredValue;
HKEY Xtmpkey;
DWORD dwDisp = 0;
LPDWORD xlpdwDisposition = &dwDisp;
DWORD dwVal = DesiredValue;
RegCreateKeyEx(HKEY_CURRENT_USER, L"SOFTWARE\\MyPath", 0L,NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &Xtmpkey,xlpdwDisposition);
RegSetValueEx (Xtmpkey, L"Desired_Value_Name", 0L, REG_DWORD,(CONST BYTE*) &dwVal, sizeof(DWORD));
Now that I am porting the software into C++/CLI environment it returns the following errors:
Error 1 error LNK2001: unresolved external symbol "extern "C" long __stdcall RegCreateKeyExW(struct HKEY__ *,wchar_t const *,unsigned long,wchar_t *,unsigned long,unsigned long,struct _SECURITY_ATTRIBUTES * const,struct HKEY__ * *,unsigned long *)" (?RegCreateKeyExW@@$$J236YGJPAUHKEY__@@PB_WKPA_WKKQAU_SECURITY_ATTRIBUTES@@PAPAU1@PAK@Z)
Error 2 error LNK2001: unresolved external symbol "extern "C" long __stdcall RegSetValueExW(struct HKEY__ *,wchar_t const *,unsigned long,unsigned long,unsigned char const *,unsigned long)" (?RegSetValueExW@@$$J224YGJPAUHKEY__@@PB_WKKPBEK@Z)
Error 3 fatal error LNK1120: 2 unresolved externals
What am I doing wrong?
Thanks in advance.
|
|
|
|
|
You need to link to Advapi32.lib.
#pragma comment(lib, "Advapi32.lib")
Or, since it's managed code, you could use the Microsoft.Win32.Registry Class[^],
which is a tad easier to use than the Win32 APIs.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: You need to link to Advapi32.lib.
#pragma comment(lib, "Advapi32.lib")
You are a "C"enius, it works! I wish one day I could be as smart.
|
|
|
|
|
It's all in the documentation
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
using namespace Microsoft::Win32;
Registry::SetValue("HKEY_CURRENT_USER\\SOFTWARE\\MyPath", "Desired_Value_Name", "Value");
Nigah M Manzoor
|
|
|
|
|
Hi
I have an SQL query which is to be executed from the server. Just before executing, I am checking if the internet is available or not.
I am using InternetGetConnectedState api to implement this.
But this call returns true, for 2-3 seconds after the network connection is lost. This causes the application to hang.
Pls verify my code and check if it is the appropriate code
---------------------------------------------------
[DllImport("wininet.dll",
SetLastError=true,CharSet=CharSet::Unicode,ExactSpelling=true,
CallingConvention=CallingConvention::StdCall)]
static bool InternetGetConnectedState(int &Description, int ReservedValue ) ;
bool IsConnectedToInternet()
{
int Desc ;
return InternetGetConnectedState(Desc, 0 ) ;
}
if (IsConnectedToInternet())
{
mysql_query(mysqlConnectorObject,sqlQuery);
return mysql_store_result(mysqlConnectorObject);
}
else
{
MessageBox::Show("Not connected");
}
----------------------------------------------------
Thanks in advance
Anvesh
|
|
|
|
|
Hi,
InternetGetConnectedState() is the best way I know to look at the Internet connection state.
You are saying it shows a slightly outdated state, but that should not be too bad. Anyway,
the connection could be lost right after you call the function, so the code that follows must
survive that anyway. Hence, use asynchronous code (on a separate thread) and give whatever you
are trying to do a timeout.
|
|
|
|
|
Thank you very much.....
Can you pls tell me how to set the time limit when starting a new thread.
Can you also suggest the most suited class to do this? I mean whether it is backgroundworker, threadpool or thread class?
|
|
|
|
|
anveshvm wrote: how to set the time limit
you either perform calls that support a time limit, or you should launch a (one-shot) timer, which:
- you cancel again when the operation succeeds
- and if the timer fires, you stop the timer and cancel the thread
anveshvm wrote: backgroundworker, threadpool or thread?
whatever fits your circumstances best; since you may have to abort it, threadpool could not be the right choice though.
|
|
|
|
|
Thank you Luc Pattyn.... I will try that way.
|
|
|
|
|
|
I have written a code to check the return value of a message box. But it doesn't work .
My code is
--------------------------------------
DialogResult^ res = MessageBox::Show("Network connection failed.,"Error in connection",MessageBoxButtons::RetryCancel,MessageBoxIcon::Warning,MessageBoxDefaultButton::Button1);
if (res == System::Windows::Forms::DialogResult::Cancel)
{
Application::Exit();
}
else if (res == System::Windows::Forms::DialogResult::Retry)
{
continue;
}
---------------------------------------------------------
Here both the if condition fails...
In immediate window, the value of res is {...}
Pls check it
Thanks in advance
Anvesh
|
|
|
|
|
anveshvm wrote: DialogResult^ res
do you want the ^ there? DialogResult is a value type, isn't it?
|
|
|
|
|
Yeah.... I got it....
Thanks alot
|
|
|
|