|
Hello Dear Friends,
I've one problem.
Suppose I've a list of open files that is opened by the application using
ShellExecute API.
How can I determine that a particular file is Open Or Close in managed c++ code?
ritz1234
|
|
|
|
|
hello
i want to open ports like 21,23,80,8080,56326 or any unknown ports
how can i do this using c++ ??
plzzz help me
|
|
|
|
|
What do you mean by "open ports"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes[^]
and so did the delete even though it told me it failed!
led mike
|
|
|
|
|
|
I encountered an absolutely insane problem with BinaryStream I/O of native classes that I was wondering if someone could shed some light on. I do have a work-around, but the whole thing just doesn't make any sense to me...
First, I have a class, "CMyBinaryIO" to handle the streaming. The Save(IntPtr myData, int iSize) method takes 2 params: an IntPtr to the data, and a integer to indicate the expected byte size. I use Marshal::Copy(...) to copy the structue into an array of bytes, and then pass that array to the BinaryStream::Write(...) method. Simple enough.
OK. Now the dirt... Consider the following, simple code snippets:
<br />
UMyParent<br />
{<br />
public:<br />
int iParentA, iParentB;<br />
};<br />
<br />
UMyHelper<br />
{<br />
public:<br />
int iHelpA, iHelpB;<br />
};<br />
<br />
UMyChild : public UMyParent<br />
{<br />
public:<br />
int iChildA, iChildB;<br />
UMyHelper uChildHelp;<br />
};<br />
If UMyChild has a Save() method that does this...
<br />
CMyBinaryIO::Save((IntPtr)this, sizeof(UMyChild));<br />
...it works. I can do a similar read operation and retrieve all the data properly. HOWEVER, I cannot read/write the binary file in any environment other than the one it was created in. In other words, if I was running the application through the IDE, I cannot read the file by running the EXE directly!!! If I create a file by running the app directly, I can't even read the file by running the exe directly on a different computer!!!
To be specific, if I created the file running through the IDE and I try to read the file by direct execution, the program acts like it read the data just fine. However, when I try to invoke any other method in the UMyChild class (maybe pChildInstance->DoSomething()), I instantly get a crash with a nice message that says something about not being able to access memory, and that the memory is possibly corrupt.
Now, here's the real confusing part. If I do this in the UMyChild::Save() method...
<br />
CMyBinaryIO::Save((IntPtr)&iParentA, sizeof(int));<br />
CMyBinaryIO::Save((IntPtr)&iParentB, sizeof(int));<br />
CMyBinaryIO::Save((IntPtr)&iChildA, sizeof(int));<br />
CMyBinaryIO::Save((IntPtr)&iChildB, sizeof(int));<br />
CMyBinaryIO::Save((IntPtr)&uChildHelp, sizeof(UMyHelper));<br />
...the the file can be created and re-read on ANY machine, and is completely cross-compatible between IDE and "live" execution. And when I call pChildInstance->DoSomething(), I don't get the corrupted memory messages!!!
I thought it might have something to do with .NET trying to write complex unmanaged types. But look closely at the code... The app does not require the UMyHelper members to be written one field at a time. The "uChildHelp" member can still be written as one chunk of data.
Does anyone have any ideas on how this could possibly be? Thank God I can at least do the single-member read/write to get around the issue, but it doesn't seem like I should have to. Why can't I pass the "this" member with the appropriate size calculation of the inherited class with all its members?
Thanks.
|
|
|
|
|
First, the code you posted does not even compile. Second you are doing what when reading? You did not post any reading code.
Xpnctoc wrote: However, when I try to invoke any other method in the UMyChild class
What method, there is no method in that class.
led mike
|
|
|
|
|
I was providing abbreviated code, as the focus of the problem is on the data members, not the methods. In "real life", the code is thousands of lines long, containing scores of members and hundreds of methods. The "DoSomething()" method I refer to is actually a method containing several hundred lines of OpenGL rendering code. This code is all straight-forward calls to the OpenGL API, using the class members to define 3D coordinates, rotations, transformations, etc. There are no tricky pointer operations or anything like that which could possibly be triggering the so-called memory errors.
Remember, all of my code works fine if either (1.) I only open the saved binary file while running the application in the same mode that created the file (IDE vs. "live" execution) OR (2.) I use the above-described work-around. Since I can get consistent behavior in either circumstance, I am convinced the problem lies in the BinaryStream class when trying to serialize unmanaged classes as one solid memory chunk.
|
|
|
|
|
Xpnctoc wrote: I am convinced the problem lies in the BinaryStream class
Ok. Good luck
led mike
|
|
|
|
|
Hi,
i developed a C++/CLR App using Visual Studio 2008. The following are the settings
1. Developed using VS2008, Featurepack was installed but not used(april) (x86 machine Vista SP1)
2. /clr:pure, pure .NET, no native code.
3. Target framework set to 2.0
4. I used cliext STL/CLR in the project.
5. Release mode
When i try to distribute the compiled exe on a Windows Xp SP2 PC, i tried the following and the program would not run.
1. I copied the exe to target machine
2. Installed .NET framework 2.0
3. Ran the app, and an error occurs - "The application failed to start because of configuration incorrect..."
I then tried to install
4. Install VCredist 2008
5. Ran the app, the app launches but a new error occurs
"System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualC.STLCLR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualC.STLCLR, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ...."
I then installed .NET framework 3.5 and the app finally runs perfectly.
What i dont understand is,
1. Why do i need the VS2008 redist? I thought this was only for native code. I didnt use any native code in my assembly, in fact i compiled as /clr:pure!
Checking the .exe using dependecywalker shows that the exe only depends on MSCOREE.DLL, no MFC,CRT etc.
2. Why did the compilation proceeded even in VS2008 when i selected the target framework to be 2.0. I used STL/CLR in my app, why didnt the compiler tell me that STL/CLR is part of .NET 3.5 and produce an error during compilation?
3. I was expecting it to run properly with .NET framework 2.0 installed only, just like any other C# code targetted for this framework. I didnt expect vcredist and .net 3.5 required..
Can anyone clarify this? Anyone had this problem, or my approach was incorrect?
Thanks
|
|
|
|
|
Might it be the manifest file that is your issue ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have linked a C++ static library to a Windows Forms Application. The static library contains a singleton:
namespace Lorenzo
{ class VendingMachine
{ ...
I am trying to invoke a function in the singleton from inside a button’s click event with the following code:
VendingMachine::Instance()-> function();
I get the following linker errors.
error LNK2028: unresolved token (0A00000D) "public: static class Lorenzo::VendingMachine * __clrcall Lorenzo::VendingMachine::Instance(void)" (?Instance@VendingMachine@ Lorenzo@@$$FSMPAV12@XZ) referenced in function "private: void __clrcall VendingMachineControls::Form1::chcolateSelectnButon_Click(class System::Object ^,class System::EventArgs ^)" (?chcolateSelectnButon_Click@Form1@VendingMachineControls@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) Vending Machine Controls.obj
error LNK2019: unresolved external symbol "public: int __clrcall Lorenzo::VendingMachine::makeSelection(int)const " (?makeSelection@VendingMachine@ Lorenzo@@$$FQBMHH@Z) referenced in function "private: void __clrcall VendingMachineControls::Form1::chcolateSelectnButon_Click(class System::Object ^,class System::EventArgs ^)" (?chcolateSelectnButon_Click@Form1@VendingMachineControls@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) Vending Machine Controls.obj
The library works with a console application, so there is no problem with the library. I would be grateful if someone could tell me what the linker errors mean or at least give me a hint as to what might have caused them. I would be very grateful for all help.
|
|
|
|
|
raydona wrote: I would be grateful if someone could tell me what the linker errors mean
Question, you are using C++ and the .NET platform to write software for a vending machine but you don't know what a link error is, is that correct? If so, why would you choose to use a language for your project that you don't know how to use? I find this confusing at best.
led mike
|
|
|
|
|
I want to install QT4 for C++, I do not know if this is a good forum to ask this question. How can I get a copy of QT4. Can anybody tell me how to get its copy and how to install
phokojoe
|
|
|
|
|
Hi, I am using Visual Studio 2005 C++/CLI and I need to create an installer for an application. The documentation I have says to create a new project and select "InstallShield 12 Projects" but there is no selection available. Does anyone have information on how to get an installer created for a completed application?
Thanks,
Buck
|
|
|
|
|
BuckBrown wrote: The documentation I have says to create a new project and select "InstallShield 12 Projects"
I don't see anything about isntallshield here[^]
led mike
|
|
|
|
|
Hi Mike,
Since I e-mailed I discovered Microsoft documentation about 'Deployment in Visual Studio'. The docs are for Visual Studio 2003, 2005, and 2008. I printed off the docs and I am trying to implement the 'Windows Installer Deployment Tasks'. The first in the list is 'How to: Install Prerequisites in Windows Installer Deployment'. Of course when I follow the instructions of selecting the project in the Solution Explorer and selecting Properties and the in the Property Pages dialog box I expand the Configuration Properties node where I am supposed to select the build page and click the Prerequisites button. Only there is NO prerequisites button to click on (what a surprise). I'll play with the other 'How to:' items in the Windows Installer Deployment Tasks list to see what other functions don't appear to exist on my machine.
Thanks,
Buck
|
|
|
|
|
Have a look at nsis[^], I use it for my installations and it's pretty easy to use.
|
|
|
|
|
I want to get the pixel width and height of a string for a particular font.
I have searched the MSDN and i found the function below
public:
SizeF MeasureString(
String^ text,
Font^ font
}
How can i use this function in my VC++ 2005 MFC project?
I have tried to use System::Drawing but failed.
Please help.
|
|
|
|
|
Are you using C++/CLI to start with, or are you just trying to use this method without building a .NET project ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am using without building a .NET project.I have used MFC application project
|
|
|
|
|
well, if you don't make it a project that supports .NET, you obvioulsy can't use .NET libraries in it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So you are saying there is no way to call managed code from unmanaged code
|
|
|
|
|
No, I'm saying you need to make your project managed, for it to call managed code. It can be mixed, it can still use MFC for some things.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
the title says it all.
Any help greatly appreciated
|
|
|
|