|
Oh, about those other links: rather than manually defining all the interfaces, you can use a technique that described in this article: http://www.codeproject.com/csharp/advhost.asp[^]
You create an IDL file (used in COM programming) to forward-define interfaces and compile that to a typelib (TLB). Then you use the tlbimp.exe utility in the .NET SDK to create an interop assembly out of that. Now you're got your interfaces defined correctly and just have to implement them! A word of caution, though: all the methods return void . Some methods require that you return S_FALSE in COM, which is still a success code. Since the return type is void , you can't return anything and you can't use a COMException because that creates an error state. In these cases, you will have to define the interface yourself and for those methods make them return an int and add the PreserveSignature=true property statement to the MarshalAsAttribute that you must add to the method.
Also, another helpful article here on CP is a book excerpt: http://www.codeproject.com/books/0764549146_8.asp[^]
These are both pretty good, but I still recommend you read that link I gave you to MSDN. It's the best way to learn about hosting the WebBrowser control or MSHTML.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
A word of caution, though: all the methods return void. Some methods require that you return S_FALSE in COM, which is still a success code. Since the return type is void, you can't return anything and you can't use a COMException because that creates an error state.
Actually, I've successfully done this in the IDocHostUIHandler.TranslateAccelerator method. The way I know I was successful is that it no longer "ate" all keyboad messages that were sent to the WebBrowser control. But yes, it's better to re-define the interface.
throw new System.Runtime.InteropServices.COMException("S_CANCEL - No custom handling",1);
|
|
|
|
|
COM+ Transaction 70-320 exam question
[Transaction(TransactionOption.Required)]
[SecurityRole("Admin")]
public class SalesProcessor
{
public void PlaceOrder()
{
//STEP 1: Code here to insert order to order table, calling method on another COM+ component participating in the transaction.
objCOM1.InsertOrder(...);
//STEP 2: Code here to update shipping table. Again, calling method on a second COM+ component participating in the transaction.
objCOM2.UpdateShipping(...);
}
}
The question is, what do you need to add in order for the transaction initiated by PlaceOrder to be executed properly. You options are:
a. Add [AutoComplete(true)] to PlaceOrder
b. Add EnableCommit( ) to "End" of PlaceOrder method.
c. ... not viable option ...
d. ... not viable option ...
The model answer is "EnableCommit" (That's option *b*). But I don't understand why. I never used EnableCommit( ) before, never had to. If I don't use [AutoComplete(true)] to automatically call SetComplete and SetAbort, I'd do it manually:
public void PlaceOrder()
{
ContextUtil.EnableCommit( ); //Is this how you use EnableCommit()? But "option b" suggested that it should be added at the END of the method after the processing... That's weird.
try
{
objCOM1.InsertOrder(...);
objCOM2.UpdateShipping(...);
ContextUtil.SetComplete(...);
}
catch(Exception er)
{
... exception prcessing ...
ContextUtil.SetAbort( );
}
}
Otherwise, [AutoComplete(true)] would do the job:
[AutoComplete(true)]
public void PlaceOrder()
{
objCOM1.InsertOrder(...);
objCOM2.UpdateShipping(...);
}
Thanks.
|
|
|
|
|
I have a WEB form associated to a C#. One of my issues is to show a file Dialog for choosing a file and process it.
How can I get this using a Web Development? In Windows forms it is clear.
|
|
|
|
|
Use the <input type="file"> tag in your ASPX page (or other HTML file). Then read the .NET SDK Documentation about HttpRequest.Files . That gives you a collection of HttpPostedFile objects that you can save to disk. It's a nice little wrapper but isn't necessary if you don't want to use it. All form data is passed as "multipart/form-data" so it's just a matter of handling multiple segments in a MIME document. I'd recommend the wrapper classes, though - they make it much easier.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have a strange problem, one thread's ThreadState could not be changed to Stopped after it runs all codes of Catch codes. But this error only occurs once in more than 5 times running. Who can explain the reason? thanks
|
|
|
|
|
Can you provide us with a sample which produce that problem
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
The following is part of my code, one of the thread[]'s ThreadState is always Running. This may occurs once when the program runs more than 5 times
private void monitorThread()
{
while(!endFlag)
{
bool flag = false;
Thread.Sleep(100);
if(groupID == maxKey)
{
for(int i = 0;i < threadNum;i ++)
{
//the program will loop to check if thread[] all stopped
flag = flag || thread[i].IsAlive;
}
if(!flag)
endFlag = true;
}
for(int i = 0;i < threadNum;i ++)
{
if(!thread[i].IsAlive && (groupID < maxKey))
{
thread[i] = new Thread(new ThreadStart(singleThread));
thread[i].IsBackground = true;
thread[i].Start();
}
}
}
private void singleThread()
{
...
catch(ThreadAbortException)
{
closeDataSource(connSrc,connODBCSrc,connDest,connODBCDest,csSrc,csDest);
}
catch(Exception ex)
{
closeDataSource(connSrc,connODBCSrc,connDest,connODBCDest,csSrc,csDest);
...
}
}
|
|
|
|
|
Hi I'm building a program that executes net send commands for lan use. An I was wondering howto format the message so it comes out multiline.
If you have any ideas on howto do this please help
btw I've already tried \n and \r\n
Help is greatly appreciated
|
|
|
|
|
I think its something like system.environment.newline
|
|
|
|
|
Ok maybe I should rephrase my question I am not using .NET to directly send the messages I am building a .bat file then executing it. SO what would the DOS cmd for doing multiline net send commands be.
Help is greatly appreciated
|
|
|
|
|
Then why did you post the C# forum?! What are we supposed to think?
Escaping characters in batch files isn't supported, nor are new lines.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Because I am creating the batch file using .NET and I wasn't sure if .NET does some wierd formatting.
|
|
|
|
|
What exactly is a .NET batch file?
|
|
|
|
|
You should use either Environment.NewLine or use a a string literal (beings with "@" where new lines and tabs are part of the string until closed):
using System;
using System.Diagnostics;
public class MsgTest
{
public static void Main()
{
string example = @"This is a test
on a new line.";
ProcessStartInfo psi = new ProcessStartInfo("net.exe",
string.Concat("send ppheath ", example));
Process.Start(psi);
}
} You could also P/Invoke the NetMessageBufferSend function. You can read more about it in the Platform SDK (Network Management, or on MSDN). It isn't hard to invoke and is pretty easy to use. Read the messaging overview link for it, though.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks so much for helpful and articulate response I will try that. =)
|
|
|
|
|
That works but only for one person... But whenever I send it to multiple users via the PIPE "|" symbol it doesn't compute the the rest of the commands because they are put on as arguments. But when I do the batch file it doesn't do the multiline messaging so I'm stumped.
Please Help
|
|
|
|
|
This is just a problem of parsing command line arguments in your program. If you're sending to multiple people, then loop through the list of people and execute the command for each one.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
When I first built my program I did that. But it takes FOREVER.
So then I thought maybe I could distribute each person into a thread.. but that would be too hectic.
So I don't know what else to do?
BTW Thx for putting up with me
|
|
|
|
|
Just thread it. "net send" takes two or more parameters (besides switches) a single user or computername and the rest of the parameters are the message. There's no way around it.
Just use a worker thread (see the ThreadPool class), passing the user/computer name as the state variable and save the message to a member field. The thread execution method gets the username and gets the value from the message field and sends the message with "net send".
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I think that it is good try to use the following API :
NET_API_STATUS NetMessageBufferSend(
LPCWSTR servername,
LPCWSTR msgname,
LPCWSTR fromname,
LPBYTE buf,
DWORD buflen
);
try to import it to you class and use it , and i think that now you can send escap characters like /n /r .....
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
Hi!
I'm writing an WinForm app in c# with VS2002 on win2000sp3 with mediaplayer9.
I have a Windows Media Player control that I added to my controlsbox
by going into the COM controls tab. This winmedplayer is embedded in the WinForm,
much like the 'Play' button, of course.
The problem I have is that whenever the application starts, it creates an exterior
Windows Media Player window that then loads the video and plays it in its own window.
My application just sits there behind with its own embedded media control that doesn't do
anything.
Here is the code for the load event of th app.:
private void frmMain_Load(object sender, System.EventArgs e)<br />
{<br />
string location;<br />
location = "C:\\Documents and Settings\\Administrateur\\Mes documents\\My Work\\Recherche et Developpement\\Videos et Audios\\Vidéo\\Q.AVI";<br />
axWinMedPlayer.openPlayer(location);<br />
}
So my question is: how may I play the video in the Windows Media Control that is embedded on my
Windows Form? -instead of having it played in a new Windows Media Player window independant of my app winform...
Thanks!
Antoine
This by our hands that dream,
"I shall find a way or make one!"
|
|
|
|
|
If you look at the documentation for openPlayer , it states that the media is opened in a new window. This is supposed to happen. Instead, assign the media source to the URL property for WM9.
You shoudl also download the Windows Media 9 SDK. It has a pretty good CHM with all sorts of information about embedding the player as well as the object model.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks!
I dont really know what I did, but now it works. And for now, that's enough for me.
I'll dig in later,
thans!
Antoine (prononced Antwone)
This by our hands that dream,
"I shall find a way or make one!"
|
|
|
|
|
I am trying to make a autometed image which will be image a new computer and add that computer domain. To do that I need to get avialble computer name from my database and change the current name and then add the computer to domain. I know how to add computer to domain but I don't know home to change the computer name. Can any one help me PL:
CJ
|
|
|
|