|
Define "embed"?
In the most direct sense, no, you can't "embed" the .EXE in your app's resources and expect to run it directly from the resources. You'll have to copy the .EXE from the resources to a file on the hard drive, then run the .EXE from the file. The file will exist, and be locked, for the entire time that .EXE is running.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
If that exe file is a .NET application you can load it in memory and run it
|
|
|
|
|
You can, but that's a big IF. Usually, when someone asks this question, it's because they want to add an .EXE that they don't have control over, like a command line utility or some other small Windows app.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
I mean to use the .exe as a part of my windows applic, as when u embed .swf file in your applic interface, but here i need to meke the user use the .exe only as a part of my window, not as a separate window of it self..
Thanks for your reply..
|
|
|
|
|
It's possible, but not recommended as it can cause visual problems for the hosted app and is not what I would call a "production quality" solution. If this "embeded" app is a .NET-based .EXE, then you can run it out of the resources of your app. If not, then you must run it from an .EXE file on the hard drive.
After it starts and puts up it's main form, you can call the Win32 API functions FindWindow and SetParent to set that window's parent to a window, like a Panel, in your application.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
the .exe is a macromedia flash .exe file, i tried to use the shockwave but it only runs .swf, i don't know if this makes a difference in the solution, and i hope if you could explain me more about finding the window and setting its parent if this is the only solution.
Thanks again..;)
|
|
|
|
|
Somehow, I just knew there was no good reason behind this...
If you launch the .EXE using the Process class, you can easily get the window handle of the .EXE. Keep in mind, I have no idea if this is going to work for your ShockWave EXE! This code assumes there is a Panel control on your form called myPanel .
[DllImport("user32.dll"), EntryPoint = "SetParent", SetLastError = true)]
private static extern IntPtr SetParent(IntPtr hwndChild, IntPtr hwndParent);
...
Process p = Process.Start("MyShockwave.EXE");
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, myPanel.Handle);
...
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
1) Create a new project, File.ReadAllBytes and then write them to a separate file ( .txt, .dat )
2) Add this file to your resources.
3) Load it from the resource at runtime and save to a new file
4) Change extension to .exe
OR
1) Change extension from .exe to .dat
2) Add as a resource
3) Load it from the resource at runtime and save to a new file
4) Change extension to .exe
?) What am I explaining at the moment? Are you trying to write a new kind of virus or just trying to make innocent programmers like me crazy?
-- modified at 12:24 Monday 7th May, 2007
|
|
|
|
|
Actually, his version of "embedding" was hosting the window of another .EXE in a form of his application.
|
|
|
|
|
I need to add a checkbox right side to list box.How can i do that.
pls let me know.
|
|
|
|
|
Why not use the CheckedListBox control instead?
Last modified: 13mins after originally posted --
|
|
|
|
|
there are 4 colums in the list view i want to show checkbox in last column
|
|
|
|
|
Then, why not use DataGridView with the column you want DataGridViewCheckBoxColumn type?
|
|
|
|
|
How do I make an installation program for multiple applications?
I have two windows applications, one web application and a database that I want to install.
I want them all in the same installationprogram. And the user should be able to choose which of the applications to install.
Additionally I want a license verification thru a webservice in the installation program. The webservice will validate the license key and download a license file when the correct license key is submitted. This license file must exist for the applications to run.
I have been looking at WIX to accomplish this but have some problems with accessing some variables when I want to change an already made installation. While using WIX I also only get one entry in “Add or remove programs”.
Since I’m not really satisfied with WIX I been thinking of writing my own userinterface and call separate MSI files made for each application. But I’m not sure if this is the right approach.
Is this the right way to do it and if not how do I accomplish this?
|
|
|
|
|
|
OK - new to generics (very...)
I have a DataTable which contains the data and I want to create classes that visually represent this data in different ways. Eg, a CheckBoxList and a ListBox.
So, hitting the keyboard I come up with :-
public class MyCheckBox : CheckBoxList
{
private BLL.myData _theData;
public MyCheckBox(BLL.myData theData)
{
_theData = theData;
DataSource = _theData.GetDataTable();
DataValueField = "code";
DataTextField = "desc";
DataBind();
}
}
public class MyListBox : ListBox
{
private BLL.myData _theData;
public MyListBox(BLL.myData theData)
{
_theData = theData;
DataSource = _theData.GetDataTable();
DataValueField = "code";
DataTextField = "desc";
DataBind();
}
}
In the front end (web) I can simply add an instance of these to the page and the databinding is taken care of. Cool. But...the code is identical in both classes apart from the derived class type, and the name I've given it.
How would I define a generic class which I can instantiate with the derived type?
I understand how to write generic classes which contain the <t> type, eg
(from memory...)
public class MyStack<T>
{
T[] arrayofMyThings;
}
but not how to create an instance of the <t> type - if that makes sense.?
Regards
Angel
*********************************************
|
|
|
|
|
If by CheckBoxList you mean CheckedListBox , then a common ancester of it and ListBox is ListControl , so make a base class that derives from ListControl and derive from that.
|
|
|
|
|
I may be being very thick here, so stay with me...
...I derive a class (MyListControl) from ListControl, add my databinding etc. No problem.
How do I go from here to get a CheckedListBox and a ListBox which derives from MyListControl and not ListControl.
When you paste the blindingly simple and obvious answer I will most probably take Christian Grauss' suggestion of buying a large book on VB and smashing myself in the face with it.
Regards
Angel
*********************************************
|
|
|
|
|
You can't change the ancestors of existing classes (Without rewriting them), but with a little extra work, you could encapsulate them into a host control.
public class GenericListBox<T> : Control
where T : ListControl
{
public GenericListBox(data...)
{
T innerControl;
if (typeof(T) == typeof(MyListBox))
innerControl = new MyListBox(data);
else if (typeof(T) == typeof(MyCheckedListBox))
innerControl = new MyCheckedListBox(data);
else
throw new ArgumentException("Some descriptive error message");
innerControl.Dock = DockStyles.Fill;
this.Controls.Add(innerControl);
}
}
...
GenericListBox<MyListBox> ctl = new GenericListBox<MyListBox>(someData);
Of course, you'd have to provide wrapper methods for many functions, or just expose the innerControl object as a ListControl and wrap any methods from below that on the inheritance chain.
Honestly though, I don't think this is the best way to do it. I'd suggest making a factory for it, and just passing an enum with the type of control to create:
public static ListControl CreateListControl(MyControlTypes ctlType, DataObject data)
{
if (ctlType == MyControlTypes.NormalListBox)
return new MyListBox(data);
else
return new MyCheckedListBox(data);
}
(MyControlTypes would be an enum, of course)
Of course, I might be misunderstanding you completely, but maybe this will spark an idea.
|
|
|
|
|
Your first suggestion is nearer to what I want. I was hoping not to use encapsulation, but this is a good start for the generic knowledge I'm lacking. Thanks for taking the time.
Regards
Angel
*********************************************
|
|
|
|
|
Hi,
Hello friends, i need your help..my problem is that i want to export my sql server database to MS access file in a specified location say in a folder..i am using .net 2.0 c# as the language...can anybody help me...
Regards
Alex.
|
|
|
|
|
It's hard to say how to help, when you give no indication of what you have done so far, and where you are stuck.
So... What have you done so far? Where are you stuck?
|
|
|
|
|
Hi,
I have a problem with the conversion of a string of type "07:30" into a time. I want to take only the time, without the date. I tried
DateTime openTime = DateTime.Now.ToShortTimeString(open);
,where open = "07:30".
Please help me with this problem.
|
|
|
|
|
Hi,
a DateTime always contains date and time.
TimeOfDay gives time since midnight.
Hence:
DateTime dt=DateTime.Parse(myInputString);
TimeSpan time=dt.TimeOfDay;
|
|
|
|
|
But if my string is like this "07:30", what can I do? Because I tried that method and my result is 00:00:00.

|
|
|
|