|
I tried the following code
StreamWriter^ f = gcnew StreamWriter(L"d:\\listfile.txt");<br />
f->Write(L"begin");
expecting a file containing the string "begin" to be created.
To my surprise, only an empty listfile.txt was created. "begin" was not written.
after a few trials, I realized I must explicitly call f->Close() to get "begin" to be written.
is it true that one of the advantages of C++/CLI over c# is that when an object goes out of scope, there is something called deterministic cleanup to close the object, or am I miseducated?
For std::fstream, I surely don't have to call close() explicitly.
|
|
|
|
|
You can use implicitly dereferenced variables. These variables use the Resource Acquistion Is Initialization (RAII) principle to do their clean up. Also, these variables have the same limiitations as automatic variables:
StreamWriter f(L"D:\\listfile.txt");
f.Write(L"begin");
...
In order to obtain a tracking handle to an implicitly dereferenced variable, you must prefix it with "%".
|
|
|
|
|
Whats wrong with my C++ code, it gets me an error.
How to use byte array in C++ by the way?
C# code:
int data_size = 146000;
int data_loop = 4096;
byte[] data_sent= new byte[data_size];
Random rnd = new Random();
rnd.NextBytes(data_sent);
for (int x = 0; x < data_size; x++)
if (data_sent[x] == 0x3f){
data_sent[x] = 0;
}
C++ code:
int data_size = 146000;
int data_loop = 4096;
Byte[] data_sent = gcnew Byte[data_size]; //Gets me error
Random^ myrandom = gcnew Random;
myrandom->NextBytes(data_sent);
for (int x = 0; x < data_size; x++)
if (data_sent[x] == 0x3f){
data_sent[x] = 0;
}
note: the c# is working and compiled but the c++ code stuck me from that error.
******************************
I just want to
know everything
|
|
|
|
|
I got it already. thanks
******************************
I just want to
know everything
|
|
|
|
|
Bros,
How to code the network speed detection?
What i mean is i want to detect the upload and download using clickbutton. When I press a button it will show to textbox1 the upload speed and textbox2 the download speed.
example:
TextBox1 = 42 kbps
TextBox = 54 kbps
Is anybody here how to do that? Much better if you can give me some links for basic.
Thanks in advance.
******************************
I just want to
know everything
|
|
|
|
|
Send some packets of data of certain size (you decide how much data you want to transfer), see how long it takes to go up and come back, then report the results in the textbox.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I am using Sql SErver 2000 Database and I begin to work with Visual c++ Net 2005;
How to to write SqlCommand::Connection to connect to SQl server 2000 in Visual c++ net 2005
I learn my self
|
|
|
|
|
I see you have lots of Database development questions. Lucky for you there are a massive number of Database Articles here on CodeProject. Use the Navigation mechanisms on the site to find the Database Articles and look through them. I am sure the information you seek is in there.
|
|
|
|
|
In addition to led mike's reply, I think it's important to consult the documentation for the
platforms/systems/etc. that you're wanting to develop for.
For example, to connect to SQL Server, you'll probably want to use the SQL Native Client.
Connection string info can be found here: Using Connection String Keywords with SQL Native Client[^]
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
String^ strConnection;
String^ strString;
SqlConnection^ cprl = gcnew SqlConnection();
cprl->ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=payroll05;server=SEM1;Trusted_Connection=Yes;" ;
cprl->Open();
|
|
|
|
|
Does that work?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
|
I am using Visual C++ NET 2005.
I want to know how to execute a query with parameters in my program
I learn my self
|
|
|
|
|
String^ strConnection;
String^ strString;
SqlConnection^ cprl = gcnew SqlConnection();
cprl->ConnectionString = "Persist Security Info=False;Integrated Security=SSPI;database=payroll05;server=SEM1;Trusted_Connection=Yes;" ;
// connectionString="Persist Security Info=False;Integrated Security=SSPI;database=Northwind;server=(local);"
// providerName="System.Data.SqlClient"
cprl->Open();
SqlCommand^ Cmd = gcnew SqlCommand();
Cmd->CommandText = "insert into barimpot(taux,minr,maxr)values(@taux ,@minr ,@maxr)";
SqlParameter^ para = gcnew SqlParameter();
para->SqlDbType = SqlDbType::Int;
para->ParameterName = "@taux";
para->Value = this->taux->Text::get();
Cmd->Parameters->Add(para);
SqlParameter^ param = gcnew SqlParameter();
param->SqlDbType = SqlDbType::Decimal;
param->ParameterName = "@minr";
param->Value = this->borneinf->Text::get();
Cmd->Parameters->Add(param);
SqlParameter^ parai = gcnew SqlParameter();
parai->SqlDbType = SqlDbType::Int;
parai->ParameterName = "@maxr";
parai->Value = this->bornesup->Text::get();
Cmd->Parameters->Add(parai);
Cmd->CommandType = CommandType::Text;
Cmd->Connection = cprl;
// ::MessageBox::Show("okkk2");
Cmd->ExecuteNonQuery() ;
|
|
|
|
|
Hi,
What does MVPs mean.
VIBIN
"Fool's run away,where angle's fear to tread"
|
|
|
|
|
|
...and in sports, it's a Most Valuable Player.
I wonder if that's the same for Code Project MVPs?
Or is it Most Valuable Person, Professional,...
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
hi,
how can i construct an Image ( to be passed to a Graphics object later ) from a memory a buffer ?
lets say a loaded GIF file in a char * buffer
Thanks in advance
A.Barakat
|
|
|
|
|
A.Barakat wrote: lets say a loaded GIF file in a char * buffer
Don't do that. Load it into an Image type.
|
|
|
|
|
If you choose to ignore led mike's advice...
I think you could store in a MemoryStream and use Image.FromStream() to create the object later.
I'm not sure why though
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Hello,
I have an MFC application that i would like to mix with Managed C++.
I changed the compiler settings and everything compiles fine.
For the moment I did not write any managed code but I have the message as follows at execution:
"An unhandled exception of type 'System.TypeLoadException' occurred in ApplicationName.exe
Additional information: Could not load type _TREEITEM from assembly ApplicationName, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null."
This message occurs before execution of the function that returns a pointer.
I have put a breakpoint in it but it is never called.
I think it is unmanaged pointer problem because I have modified the function to return a reference to CWnd and everything was Ok.
below is the code snipped, Could please help me because I am 100% newbee with C++/CLI
Declaration
private:
CWnd* m_pView;
CWnd* CreateTreeView();
Definition
BnBPaneView::BnBPaneView():m_pView(NULL){}
int BnBPaneView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_pView = CreateTreeView();
etc..
.
.
.
}
|
|
|
|
|
i don't see anything involving managed code at all here so I'm not sure how the problem could
be with unmanaged pointers.
BnBPaneView is an unmanaged class, right (derived from an MFCclass)?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Yes it is unmanaged, derived from CWnd:
class BnBPaneView : public CWnd
Actually all what I have done is to change the compiler settings recommended in the MSDN:
Use managed extensions = yes
Enable minimum Rebuild = no
basic runtime checks = default
And before changing those settings, the application was working fine.
|
|
|
|
|
|
Does that mean that those who want to mix their applications must specify #pragma unmanaged before all their functions that are implemented with native code?
It is a hudge work to pass through thousands of functions.
While reading some articles on the subject, I understood that thanks to JIW ( just it works), there is nothing to do except changing the compiler settings.
And regarding MFC applications, following directives
#using <mscorlib.dll>
#using <system.windows.forms.dll>
using namespace System;
using namespace System::Windows::Forms;
are to be added in the stdafx.h file.
|
|
|
|