|
this is called serialization.
i think that if you posted your question here, it's because you'd like to do it in Managed C++.
i don't have the solution, but there is certainly some articles about how to Serialize/Deserialize class instances.
|
|
|
|
|
I am using Borland C++ (v4.5) and trying to write a program to input output one byte to the parallel port. It used to be fairly easy prior to XP. I have seen various things on the web that are supposed to get around the hard bit of overriding XP's control over the port, e.g.
www.geekhideout.com/iodll.shtml
but I can't get them to work. I think I must be doing something wrong in the way I include the .h and .dll files into the project. What is the difference between starting an ordinary .cpp program and a project.
Can anybody offer me some advice please
Geoff
|
|
|
|
|
|
I am currently using Visual Studio 2003, I see that when I choose a new project for C++ I can not pick any project to develop on a mobile device. C# has this option.
Is it possible to build an application in C++ with managed extension (with \clr ) for mobile development? If so does anybody got a link or so to point me in the right direction?
Greetings,
Davy
|
|
|
|
|
hi everyone i have a project like that :
You are supposed to develop a garage system simulator. Possible system classes are car owner, car, garage, fee, payment.
Take into account the following assumptions:
1- A customer may take parking , washing, polishing services.
2- There is predefined parking fee list. Important point is to hold time chart for a car.
3- Washing service choices are outer or all.
4- Payment includes all services.
5- Manager should be able to check the numbers of car and the money. This report may be taken daily or for a duration.
please help.
if you write c++ code i will be so presuade. thanks a lot.
-- modified at 11:50 Tuesday 4th April, 2006
|
|
|
|
|
Sir,
You need to start writing your simulator application. While you are programming and you have a specific question on coding, please post your question here if you are using Managed C++ or C++/CLI. Otherwise, not too many developers are "nice" enough to write this project for you.
George
-- modified at 18:45 Tuesday 4th April, 2006
|
|
|
|
|
do your homework yourself
|
|
|
|
|
Did you read this[^] before posting ?
-- modified at 5:08 Wednesday 5th April, 2006
Link corrected
|
|
|
|
|
ok guys, i will start my project and if i have a specific question i will ask it. thanks a lot.
|
|
|
|
|
I`m writing a dll in C++ that uses managed extensions. Its purpose is to wrap a .NET library I wrote so that I can use it in an existing C++ project I have here.
All goes smooth, but I got some problems now calling a C# function of the dll that has an out parameter.
function definition in C#:
public enumMsgType DoYourThing(string sMethod, ref Single Cnt, out string outParam, string inParam)
my wrapper function is:
CMyWrapperObj::wrMessageType CMyWrapperObj::InvokeMethod( LPCTSTR sMethod, float& nNum1, CString& sOutParam, LPCTSTR sInParam)<br />
{<br />
return static_cast<CMyWrapperObj::wrMessageType>((*this)->InvokeMethod(sMethod, &nNum1, sOutParam,sInParam));<br />
}<br />
I get a build error on the sOutParam parameter:
MyWrapper.cpp(60) : error C2664: 'COMCaller::ManagedObj::DoYourThing' : cannot convert parameter 3 from 'CString' to 'System::String __gc *__gc * '
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
So I guess I need to call this function not with a CString parameter.. .I also tried a std::string variable to pass in the parameter list, but also that doesn^t work... It`s probably something obveous that I`m overlooking, but if you could point me to it I would be gratefull
Greetings,
Davy
|
|
|
|
|
why don't you use LPCTSTR parameter, or ever simple, System::String ?
|
|
|
|
|
LPCTSTR because the string isn^t a constant, it will get a new value in the .NET function that will be called.
System::String .. Since I don^t want to have any managed types in my header files I guess my mind didn^t get to that point.
Well thanks a lot, got the thing compiled now, I can now focus on the next issue!
|
|
|
|
|
Hi,
I've to write a query which requires a function similar to "sprintf" in C
For e.g.
String *query; // in c++.net
sprintf(query, "Select * from table_name where number = %d", no); // in C
How can this be done in this environment?
Thanks,
Kranti
|
|
|
|
|
Kranti1251984 wrote: I've to write a query which requires a function similar to "sprintf" in C
For e.g.
String *query; // in c++.net
sprintf(query, "Select * from table_name where number = %d", no); // in C
How can this be done in this environment?
Hi Kranti1251984,
yes, there is actually. For instance you could use:
System::String::Format(...)
<br />
String^ s = String::Format(<br />
"(C) Currency: . . . . . . . . {0:C}\n" +<br />
"(D) Decimal:. . . . . . . . . {0:D}\n" +<br />
"(E) Scientific: . . . . . . . {1:E}\n" +<br />
"(F) Fixed point:. . . . . . . {1:F}\n" +<br />
"(G) General:. . . . . . . . . {0:G}\n" +<br />
" (default):. . . . . . . . {0} (default = 'G')\n" +<br />
"(N) Number: . . . . . . . . . {0:N}\n" +<br />
"(P) Percent:. . . . . . . . . {1:P}\n" +<br />
"(R) Round-trip: . . . . . . . {1:R}\n" +<br />
"(X) Hexadecimal:. . . . . . . {0:X}\n",<br />
-123, -123.45f); <br />
Console::WriteLine(s);<br />
In addition i would like to point out, that it would be more secure to use parameters when constructing dynamic SQL statements.
best regards Tobias
|
|
|
|
|
2beeIn addition i would like to point out, that it would be more secure to use parameters when constructing dynamic SQL statements.
Just to add to Tobias' quoted comment, SQL Injection can be a big problem. For instance, a user can "inject" a DELETE statement into your programmically built SQL string and do some serious damage. Using parameters, SQL injection is impossible.
|
|
|
|
|
Hello,
Is it possible to include a .dll in a /clr:pure project?
I am currently using unmanaged code for this.
I was wondering if it is also possible with a /clr:pure project which does not allow native C++?
Including a .dll can be done with C#.
(Full setting is "Pure MSIL Common Language Runtime Support (/clr:pure)" in the project properties -> General)
best regards,
Jan Timmerman
|
|
|
|
|
What do you mean by 'include a dll'?
If ur question is whether an unmanaged dll can be used in a /clr:pure c++/cli project, Yes, You can do. Inlcude the lib and header file to c++/cli project and you can create objects of unmanaged clasees in the dll or u can call unmanaged functions in that dll.
You can use a com dll as well using the #import
c++/cli is the only language where u can mix both managed unmanaged code.
deoes this make sense...mil10.
|
|
|
|
|
Thanks for your reply:
Well that was about where I was aiming at.
I never heard of the "#import" directive before so I will have to look into that. I have not too much experience with Visual studio.
Perhaps I should explain a little more about the situation.
Currently I have a ".lib" and a ".dll" generated by Compaq Visual Fortran.
I've declared the function called from the .dll as follows:
<br />
extern "C" void __declspec(dllimport) extiteratie( [arguments] )<br />
First I get the warning:
<br />
TFortranInterface.cpp(27) : warning C4272: 'extiteratie' : is marked __declspec(dllimport); must specify native calling convention when importing a function.<br />
after that an error
<br />
error LNK2031: unable to generate p/invoke for "extern "C" void __clrcall extiteratie( float*, float*, (...) float* )" (?extiteratie@@$$J0YMXPAM000000000000000PAH110@Z); calling convention missing in metadata<br />
(After this an unresolved token error which is most likely caused by the previous error.)
I am currently using a native class as interface because I need to pass the function in the .dll a set of pointers which will be filled with results.
The questions:
1. With /clr:pure I cannot use that native class?
2. Any idea what the error could mean (and/or perhaps an alternate declaration for the function in the .dll?)
(3. what does #import do?)
best regards,
Jan Timmerman
|
|
|
|
|
1. With /clr:pure I cannot use that native class?
Yes, You can use native class in a /clr:pure c++/cli project.
2. Any idea what the error could mean (and/or perhaps an alternate declaration for the function in the .dll?)
Note the warning you got: "warning C4272: 'extiteratie' : is marked __declspec(dllimport); must specify native calling convention when importing a function."
Your function declaration was:
extern "C" void __declspec(dllimport) extiteratie( [arguments] ) : Here you havn't mentioned any calling convention. So compiler took the clr only calling convention __clrcall . Now see the error message you got - "error LNK2031: unable to generate p/invoke for "extern "C" void __clrcall extiteratie( float*, float*, (...) float* )" (?extiteratie@@$$J0YMXPAM000000000000000PAH110@Z); calling convention missing in metadata"
This means that C++/CLI compiler is not able to generate the p/invoke for a function which is reserverd for CLI only (because of the by default __clrcall calling convention).
So to fix this, change the function declaration as below:
extern "C" void __stdcall __declspec(dllimport) extiteratie( [arguments] )
Here if the calling convention of extiteratie is soemthing else other than __stdcall , then put the same instaed.
3. what does #import do?)
You dont have to worry abt #import as ur dll is not a com dll. It is for using com components.
Hope this will help...mil10.
|
|
|
|
|
Great, it works!
i've modified the function call to
<br />
extern "C" void __cdecl extiteratie( [arguments] )
(from the error messages I noticed the compiler ignores the "__declspec(dllimport)" part when including __cdecl)
Also I added an underscore to the function export in the Fortran code which was needed by __cdecl.
An alternative is (most likely but not tested) to use __stdcall in the export. I do not think it makes much difference whether I use __stdcall or __cdecl?
Thanks a lot!
Jan Timmerman
|
|
|
|
|
wud ne body b willing to explain to me how to create a madlib while adding in the fact that one must "flush" it?
J-Dub
|
|
|
|
|
I am using CFileDialog for a "save as" where I have to choices for file types: All Files or Avi Files.
I noticed something very strange and discovered it is DIRECTLY related to Managed C++.
First of all, the "save as" function is done correctly, so 99% of the problem is solved.
It comes up with All Files and indeed shows all files. The problem comes when I change to show only avi files. The window goes blank. If I go back to all files, it stays blank. Only if I choose a different folder is it refreshed properly (with either all or avi files).
I tried it in Paint and there if you change the file type, the window refreshes correctly. In CFileDialog it doesn't.
My code is:
CFileDialog filedlg( FALSE, "avi", // default extension
"mip1.avi", // current file name
OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_LONGNAMES,
"All Files (*.*)|*.*|Avi Files (*.avi)|*.avi||", NULL);
Since starting to look into this problem I found out that the problem exists ONLY when I use Managed extensions. When I turn off Managed extensions, it refreshes perfectly, like it has always done.
To complete the picture I tried GetSaveFileName( &ofn) and that shows exactly the same behaviour.
Has anyone else seen this, or can tell me what is wrong?
Thanks,
Ilan
|
|
|
|
|
Hi,
I saw many different ways to convert a System::String to a char in MSDN2... But it doesn't work.
example...
private: System::Void openFileDialog1_FileOk(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) ...
I need to convert the openFileDialog1->File to a char named caminho to use this in other functions that only supports *char...
Please help-me...
|
|
|
|
|
good morning,
how about this one:
// maybe you'll have to set your project settings to UNICODE
array <Char>^ myCharArray = openFileDialog1->FileName->ToCharArray();
pin_ptr<Char> caminho = &myCharArray[0];
regards Tobias
|
|
|
|
|
How do I use the args in the "int main(array<System::String ^> ^args)" main() style?
I used to use the "argv[1]" for the "normal" "int main(int argc, char* argv[])". And I want to use the args in the "new" just like this one.
Something for "if (argv[1] != NULL)"
or for "GetShortPathNameA(argv[1], filepath, 255);"
What I have to do?
I'm new in C++... But I need to use this...
Thanks,
Leonel
(Sorry by the poor english, I'm Brazillian.)
|
|
|
|