|
I am writing a method in C# and I need to execute applications from it. I have used ShellExecute in C++ before. So I thought that I would be able to make a managed extension. For the method, it was suppose to take in a string, the name of the application to execute. I got an error message when I used String, string, CString. I don't know what to use as the type. So I tried something different in C#, I used
Process myProcess = new Process();
myProcess.StartInfo.FileName = "Notepad";
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
myProcess.Start();
but that did not show the notepad application (I didn't try any other application program yet). The process is running in the background, I check with task manager. The problem is that I don't know how to write managed code and I don't know how to use C#. I am new to both.
Thanks for any help
|
|
|
|
|
I used the exact same code that you did (I copied and pasted just to be sure), and it worked.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
This is how I have done it in the past :
<br />
FileInfo launchfi = new FileInfo("myprogram.exe");<br />
if (launchfi.Exists)<br />
{<br />
Process mainapplication = new Process();<br />
mainapplication.StartInfo.FileName = launchfi.FullName;<br />
mainapplication.StartInfo.WorkingDirectory = launchfi.Directory.FullName;<br />
mainapplication.StartInfo.UseShellExecute = false;<br />
<br />
try<br />
{<br />
mainapplication.Start();<br />
}<br />
catch<br />
{<br />
MessageBox.Show("Unable to start application.");<br />
}<br />
}<br />
|
|
|
|
|
hi,
I'm a beginner of C#,
recently, I have to handle a project which need a dash line object.
I know I need to make my own control, however, I can't find any solution and idea at all.
actually, the application is composed by a panel, and a picture box. The picturebox is placed inside panel, and the image will show inside pictureBox (fixed). Then I need to make 2 dash line that are able to "drag" left/right like a splitter in order to let user measure the length of picture.
Does any experts made an example like this?
or do you know where has this type of example?
I'm quite urgent to do this. Please help and guide me on right way..
Thank you very very much !!
|
|
|
|
|
|
Hi, Leppie,
Thank you very much for your reply. You did a great job, however, it's a little bit hard for me. I'm sorry, I'm stupid...
I don't need to do such powerful as your's, I just need a control that is movable dash line. I would like to move the line over picture. I know it's bascially as same as your's. But could you explain it more to me, or teach me how to make this control.
Thank you very very much
|
|
|
|
|
Hi all. I apologize to the mods if this is against the rules..I'm not sure where to find the rules anymore.
Just announcing my new website meant to be a code developer type of website like this one, only on a much smaller (mostly personal) scale. Please feel free to stop by and discuss things.
KingTermite.Net
KingTermite
There are only 10 types of people in this world....those that understand binary, and those that do not.
|
|
|
|
|
Hi.
I'm writing a new app in C# where i'm using an old C++ app written in Power++. in my C# app i'm writing files whisch will be read by the C++ app. the C++ app is started from my C# app using the "proces" class in the .NET framework.
Before the C++ app will read the files it has to recieve a user event (WM_USER Event) from my C# app. My question is this:
How do i genereate a event in my C# app with the appropriate data that will be seen by the c++ app?
for the record: i Usually code C#. I do not code C++. i can read it but not well.
I have access to the sourcecode of both app's but I am not interestest in changeing the C++ app.
I have pasted a small part of the c++ app where i think the "eventlistener" is created.
------------------
WBool Form_POSManager::Form_POSManager_User(
WObject * source,
WUserEventData * event )
{
FindPOSFiler(event->data);
return FALSE;
}
----------------
I have abserlotely no idea how i am going to generate or send the event from C#.
Can anyone help me out?
//finger
|
|
|
|
|
i found the solution:
http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=119342&Page=1#119937
|
|
|
|
|
i found the solution:
http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=119342&Page=1#119937
|
|
|
|
|
Hello,
I'm currently looking in to making a modified dropdown control, and as with the standard dropdown in .NET API I want to be able to let it extend outside
the bounds of the window containing it if necessary. So how do I go about to do this? I really don't know where to start (or, I would give WIN32 API as an educated guess, but...)
does anyone have any information/hints/references to help me?
/Bjorn
|
|
|
|
|
I am new in C#, can someone please tell me what's the best solution writing a console application for this scenario:
A manufacture sells the following vehicles: trucks and motocycles. They want to be able to track the vehicles by model, color, and price. In additioni to the above shared information, they also need to track engine type for trucks. Also, they need to track tire size for motorcycles. Finally, they want a function to display the data for their vehicles.
Thanks in advance.
CT
|
|
|
|
|
|
is it possible to manipulate an obj inside an arraylist with a reference to it that is outside the list. more clearly - i create an obj and then add it to arraylist. but i still have a reference to the obj. can i use this ref to manipulate the obj values even if it is in an arrayList.
"Excellence is never an accident" - JJC
|
|
|
|
|
If the object is a class then yes you can.
if its a struct then you can't as it will be copied.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hi all
I have a problem with visual studio .net. I insert a breakpoint, but it says "The breakpoint will not currently be hit. No symbols have been loaded for this document". What can i do fix this?
Note: I am running the project in debug mode, not release mode.
|
|
|
|
|
This happens to me quite a bit....
1st, make sure in your project properties that the setting to Generate Debug Info is set to true. If it isnt, simply set it to be so an recompile.
If it is already true, set it to false, recompile, back to true, recompile. 9/10 that will get my breakpoints working again.
Good Luck!
|
|
|
|
|
Morning guys and girls,
I'm trying to get a list of methods from a COM object that I only know the ProgID of.
This is the code I thought would work...
---
Type t = Type.GetTypeFromProgID("xxx.yyy");
if (t != null)
{
MemberInfo[] members = t.GetMembers();
for (int i = 0; i < members.Length; i++)
MessageBox.Show(members[i].Name);
}
---
But this only seems to return methods that exist in c#'s object object (if you know what I mean!).
Anyone have any ideas?
Thanks in advance,
Simon.
|
|
|
|
|
I did it from C++ like this. (I am still learning C#)
1. Get the ITypeLib by using LoadTypeLibEx[^] function.
2. Get the number of type descriptions from typelib via GetTypeInfoCount[^] method.
3. Then I used GetTypeInfo[^] and GetTypeAttr [^] methods.
4. Now play with TYPEATTR[^] members which contains all the info.
Use the links provided to find the solution for C#. Let me know how it works.
"...if you don't want to hear things that piss you off don't piss off other people. SIMPLE." - Steven Hicks This signature was created by "Code Project Quoter".
|
|
|
|
|
Thanks Kant,
I am using the LoadTypeLibEx method, and then using a System.Runtime.InteropServices.TypeLibConverter to convert it to an assembly. I can then get all the objects in the DLL by using reflection (GetTypes etc).
Cheers.
|
|
|
|
|
Hmm.. Using TypeLibConverter, if you don't mind can you post the code snippet. I am just curious. Anyway I tried like this C#.
LoadTypeLibEx(strCOMLibName, REGKIND.REGKIND_DEFAULT, out oCOMTypeLib);<br />
if(oCOMTypeLib != null)<br />
{<br />
TYPELIBATTR oTypeLibAttributes = new TYPELIBATTR();<br />
Type oType = oTypeLibAttributes.GetType();<br />
..<br />
..<br />
oCOMTypeLib.GetLibAttr(out hwndTLibAttr);<br />
"...if you don't want to hear things that piss you off don't piss off other people. SIMPLE." - Steven Hicks This signature was created by "Code Project Quoter".
|
|
|
|
|
This is what I did Kant:
LoadTypeLibEx(lstrFilename, RegKind.RegKind_None, out typeLib );
if (typeLib != null)
{
AssemblyBuilder asm = converter.ConvertTypeLibToAssembly(typeLib, "tmplib.dll", 0, eventHandler, null, null, null, null );
Type[] types = asm.GetTypes();
}
Once you have this, you can loop around the types to get the methods...
for (int i = 0; i < types.Length; i++)
{
MemberInfo[] meths = types[i].GetMembers();
for (int j = 0; j < meths.Length; j++)
{
MessageBox.Show(meths[j].Name);
}
}
Hope this is useful to you. Thanks again for your help,
Simon.
|
|
|
|
|
After your post, I read the information about TypeLibConverter . I went in a different route to get the info. (I followed the same path I did in C++)
Anyway, I want to write a small article about this. Do you want to jump in?
Except for MSDN, I haven't found any useful info about reading COM information via C# anywhere.
"...if you don't want to hear things that piss you off don't piss off other people. SIMPLE." - Steven Hicks This signature was created by "Code Project Quoter".
|
|
|
|
|
Hi
I don't really think I know enough to write an article to be honest. Also, I'm not very good at explaining stuff in a concise fashion!
Feel free to ask me any questions or use any of my code in the article though (and I'll rate it a 5 for ya! ).
Cheers,
Simon.
|
|
|
|
|
I have created a UserControl that allaws a DataObject to be dragged.
The DataObject contains a Bitmap and string.
When the DataOject is dropped into MSWord. MSWord displays the text.
Does anyone know our to force MSWord to display the Bitmap.
I have tried adding the Bitmap to the DataObject first followed by the string.
But this has no effect.
|
|
|
|