|
Checking for the WM_QUERYENDSESSION and WM_ENDSESSION worked perfectly! Thanks Gaul.
|
|
|
|
|
Anyone know where I could find a sample app that will run a console app & display its output in a windows form?
|
|
|
|
|
Daniel Bright wrote:
Anyone know where I could find a sample app that will run a console app & display its output in a windows form?
Do you want the same identical output on both the console and the Win Form?
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
I don't want the console to display at all, I just want all output to be directed to a textbox or something.
This [^] article explains exactly how it is done in C++, I was just hoping for a C# version of it that is more simplified.
|
|
|
|
|
Use the System.Diagnotics.ProcessStartInfo class, set the UseShellExecute property to false, and the RedirectStandardInput , RedirectStandardError and RedirectStandardOutput properties to true. You can then use the StandardInput , StandardError and StandardOutput properties of the Process object to send input to the program and read the output.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hi Eveyone.. I have sample code of install shield express serial key validation dll. I want to convert this c++ code to c# but i don't know where should i start. I need your help.. Thanks...
Here is the code:
<br />
#include "stdafx.h"<br />
#include <tchar.h><br />
#include <stdlib.h><br />
#include "ValidateSN.h"<br />
<br />
BOOL APIENTRY DllMain( HANDLE hModule, <br />
DWORD ul_reason_for_call, <br />
LPVOID lpReserved<br />
)<br />
{<br />
return TRUE;<br />
}<br />
<br />
LONG WINAPI ValidateSN(HWND hwnd, LPSTR szSrcDir, LPSTR szSupport, LPSTR szSerialNum, LPSTR szDbase)<br />
{<br />
if (_tcslen( szSerialNum ) != SERIALNUMBER_LENGTH)<br />
{<br />
#ifdef _DEBUG //Display Debug information<br />
MessageBox(GetFocus(), "Serial Key is Invalid!", "Validation Failed", MB_OK); <br />
#endif<br />
return VALIDATION_FAILED;<br />
}<br />
<br />
TCHAR szTemp[255];<br />
_tcscpy(szTemp, szSerialNum);<br />
<br />
<br />
LPSTR szField1 = _tcstok( szTemp, TOKEN_SEPERATOR );<br />
LPSTR szField2 = _tcstok( NULL, TOKEN_SEPERATOR );<br />
LPSTR szField3 = _tcstok( NULL, TOKEN_SEPERATOR );<br />
<br />
#ifdef _DEBUG //Display Debug information<br />
CHAR szTmp[1024];<br />
wsprintf(szTmp, "szSerialNum=%s. \nField #1=%s \nField #2=%s \nField #3=%s", szSerialNum, szField1, szField2, szField3);<br />
#endif<br />
<br />
if (ValidateField1(szField1) != VALIDATION_SUCCESS)<br />
{<br />
#ifdef _DEBUG //Display Debug information<br />
MessageBox(GetFocus(), "Serial Key is Incorrect!", "Validation Failed!", MB_OK); <br />
#endif<br />
<br />
return VALIDATION_FAILED;<br />
}<br />
else if (ValidateField2(szField2) != VALIDATION_SUCCESS)<br />
{<br />
#ifdef _DEBUG //Display Debug information<br />
MessageBox(GetFocus(), "Serial Key is Incorrect!", "Validation Failed!", MB_OK); <br />
#endif<br />
<br />
return VALIDATION_FAILED;<br />
}<br />
else if (ValidateField3(szField3) != VALIDATION_SUCCESS)<br />
{<br />
#ifdef _DEBUG //Display Debug information<br />
MessageBox(GetFocus(), "Serial Key is Incorrect!", "Validation Failed!", MB_OK); <br />
#endif<br />
<br />
return VALIDATION_FAILED;<br />
}<br />
else<br />
return VALIDATION_SUCCESS;<br />
}<br />
<br />
LONG ValidateField1(LPSTR szField1)<br />
{<br />
if (_tcsicmp (szField1, SERIALNUM_FIELD1) == 0)<br />
{<br />
return 1;<br />
}<br />
else<br />
return -1;<br />
}<br />
<br />
LONG ValidateField2(LPSTR szField2)<br />
{<br />
<br />
long lNumToValidate = atoi (szField2);<br />
<br />
if ((lNumToValidate % 3) == 0)<br />
return VALIDATION_SUCCESS;<br />
else <br />
return VALIDATION_FAILED;<br />
}<br />
<br />
LONG ValidateField3(LPSTR szField3)<br />
{<br />
return VALIDATION_SUCCESS;<br />
<br />
}
|
|
|
|
|
learn C#
the string object is your friend and the Convert class is your buddy
LPSTR becomes string
all the _t type functions have equivalent methods for string objects
and the atoi can be handled by a Convert.ToInt32(...)
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Thanks. but my problem is entry point of function. install shield does not found my function written in c#. i have to export function for external use like this
extern "C" _declspec (dllexport) <br />
int validatethis(const char * szSerial)<br />
{<br />
.....<br />
...<br />
}<br />
i dont know how it is make in c#..
|
|
|
|
|
ah - I see - I assumed that you were just wanting to use the same code in some C# project.
daft question but why are you writing it in C# if it works fine with installshield in the form that you have it?
Anyway what you have to look into is called 'interop', but I don't think you can as I think MS worked on the principle that C# will want to call API but not the other way - a .NET dll is not the same as a normal dll and has different structure and thus LoadLibrary etc will not cope
I think what you might have to do is wrap the C# object in managed C++ (which I think you can export)
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Thank you so much... I think i understand. I want to use c# because i use well c# then c++. I will try to do that.. Thanks again..
|
|
|
|
|
Hi all,
I wanna do something like what is done by WinZip or WinRar programs.
when i rightClick any file i found My Menu item after copy & paste for example.
anyone know how to do such things in C#
thanks
plextoR
|
|
|
|
|
What you are talking about here is a Explorer Context Menu Shell Extension.
There are a series of articles written by Mike on how to do this using VC++. If you would like to do the same in C#, there is lot of work to be done. There is a technology sample that comes along with framework sdk, which would help you go about this thing.
Here are the links that could help
The following is one of the samples, but does not directly what you want, but gives you an understanding of things involved in writing one.
http://www.codeproject.com/csharp/dateparser.asp[^]http://www.codeproject.com/shell/shellextguide1.asp[^]
The sample from framework sdk
\FrameworkSDK\Samples\Technologies\Interop\Applications\ShellCmd
Hope this helps.
Cheers
Kannan
|
|
|
|
|
If you don't need the functionality of a COM shell extension then you could get away with some quick registry additions.
Add
HKEY_CLASSES_ROOT\Folder\shell\&Command To Display\command
and set (Default) to pathtoexe\program.exe
You can play with "'s and the command line arguments passed (%1) if needed.
This will display for any folder that's right-click on. You could instead add it under the HKCR\Directory tree or create your own association. It just looks for the shell & command keys.
|
|
|
|
|
Hi
Is there any way to create a control in C# and use it in non .Net (MFC 6) program?
thanks
|
|
|
|
|
Um... no.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Yes, but it isn't cut and dry and NOT supported by Microsoft (in the early beta's it was possible, but was later removed and now the only supported non-.NET host is IE).
Essentially you have to implement all the COM interfaces that a standard ActiveX control would implement. I believe there is an article here on CP which explains what you need to do, Exposing Windows Forms Controls as ActiveX controls[^].
You will probably have to do some conversions between the class names used in Beta 1 and the ones that made it into 1.0 (for example System.WinForms is now System.Windows.Forms and System.WinForms.RichControl is now System.Windows.Forms.Control or System.Windows.Forms.UserControl ).
James
- out of order -
|
|
|
|
|
It sounds like you would just have to implement the COM registry stuff yourself. MS probably pulled this feature to get away from having to support older systems and concentrate solely on a .NET push. After all activex is just an exe done in COM and it's rather easy to write com controls in assembly language once you see which registry entries + class interface methods are expected.
|
|
|
|
|
grv575 wrote:
MS probably pulled this feature to get away from having to support older systems and concentrate solely on a .NET push.
The response I heard was it was pulled because they didn't have time to test all possible permutations of how it would be used. By only supporting IE as the host, they had much less they needed to test/debug.
At the time they said the feature would be coming back later, after it could be tested. Who knows what Everett/v1.1 brings?
James
- out of order -
|
|
|
|
|
How do I find out which item is activated / doubleclicked in an ListView DoubleClick / ItemActivate event?
I guess I have to cast the EventArgs to something very clever - but what, and how to find out?
TIA
Peter
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
|
Use the GetItemAt method of the ListView passing in the current mouse position in client coordinates (you can get the position by the MousePosition static property of the Control class).
James
- out of order -
|
|
|
|
|
How can i run C#.NET applications on Linux?
Jassim Rahma
|
|
|
|
|
Well...
You can run the Shared Source Common Language Infrastructure[^] on FreeBSD and MacOSX.
However, for Linux, you're going to want to look at The Mono Project[^]
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
Hi, I need a way to find if the computer is connected to internet at the time my program runs on. Is there any?
karanba
|
|
|
|
|