|
i want to connect my SQL server 2005 data base through c++ code.. please soem one help me..
more precisely, when ever there is a update in the data base i have to pass the values of the field to another application thru c++ code..
|
|
|
|
|
|
Hi. I am a newbie at managed c++. The thing I am trying to is pass an "managed unsigned char array" reference between objects, so that all the objects will be using the sama array, and assign newly created arrays to that array reference. I can't pass the reference in all the function calls, so I am trying to pass the array reference in the constructor and store it in an managed array reference variable. But when I try to declare that variable I am getting, "cannot declare interior __gc pointer or reference as a member of 'TestClass'". How can I achieve my goal? Hope I made myself clear. Thanks in advance
|
|
|
|
|
randomVariable wrote: so I am trying to pass the array reference in the constructor and store it in an managed array reference variable
Did you mean something like this?
ref class TestClass{
array<System::Char ^> ^arr;
public:
TestClass(array<System::Char ^> ^arr){
this->arr = arr;
}
}; This code will compile correctly.
|
|
|
|
|
Thanks for your answer. I'm using the old syntax.And that is not I am trying to do. I want to store a reference to reference type as a class member, so I would be able to assign a completely new array to that reference. Like this:
typedef unsigned char ByteArrayType __gc[];
__gc class TestClass
{
private:
ByteArrayType& arrayRef;
public:
TestClass(ByteArrayType& arrayRef)
{
this->arrayRef=arrayRef;
}
}
As I said before, I am a newbie at managed c++ so it is possible there are syntax errors, or logic errors. The compiler gives the error in the bold line..
modified on Wednesday, December 24, 2008 3:27 PM
|
|
|
|
|
A __gc * IS a reference, so the type should be __gc *.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
My problem: I made
1- A new MFC application (exe) (c++ .net 2005), dialog based.
2- Get from the toolbox a control which is "Picture Control".
3- Set the type of the control to Bitmap in the property window of the control.
4- Add new bitmap to the resources at which this bitmap is 32 bit color depth picture.
5- Set the Image property of the "Picture" control to the previous Bitmap ID in the
property window of the control.
6- Build and run the application on WinXP and make sure that the appliction is enabling XP theme.
Note to enable it if it is not enabled write this line in "Additional Manifest Dependencies"
in linker node, in Manifest file Node:
type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*'
When I do all this steps just part of the picture is displayed while if take the application and run it in Win server the picture is displayed perfert.
anyone knows the reason and a solution for that???
thanks
|
|
|
|
|
fire storm wrote: 1- A new MFC application
Please post on the correct board![^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
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
|
|
|
|