|
Heath, problem here is of accessing my local mail client from a windows service. Guess that would remain the same for any language at all. This code works for me as a stand alone exe. It takes the default profile and password of my client (microsoft outlook). MSMAPI is Microsoft Mail API underlying outlook.
Problem comes when this exe is spawned from a windows service as a separate process. Its on the SignOn() method, that it says method not supported.
|
|
|
|
|
I know what MAPI is, I'm just wondering where you got this component. Is it just a RCW (COM interop assembly)?
In any case, is the "Interact with Desktop" option enabled for the service. Since it executes your MAPI client (Outlook in your case), it must be able to interact with the desktop.
-----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-----
|
|
|
|
|
Your service is probably using the default "Local System" account, which does not have access to your e-mail profile. What you have to do is reconfigure your service to run under your own account, or the account that owns the e-mail profile:
1. Open the "adminstrative tools" menu, click the services submenu to open a window displaying the list of all services.
2. Double click your service in the list and then click the "Logon" tab.
3. Enter the correct user name and password, click "OK" to close the window.
4. Restart your service.
My articles and software tools
|
|
|
|
|
Not sure where to post this. Is there a builtin function or easy way to convert upper-unicode characters to their escaped HTML equivalent? I.E. I have a string defined and written out to HTML as:
string testString = "[\u2026]";
writer.Write(testString);
What I would like in the resulting HTML output is "[…]", but what I get is the actual unicode byte. I have tried HtmlEncode and various Text.Encoding but they do not handle this... Is there any builtin functions to handle this, or is a funciton needed to loop through the bytes in the string and escape the characters?
FYI: This is just a simple test, the actual data is from an outside data-source and has these characters in it which I need to escape.
|
|
|
|
|
See the HttpUtility.HtmlEncode method. It's static and can be used outside the scope of ASP.NET.
-----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-----
|
|
|
|
|
Actually that was the first thing I tried and it doesn't work:
string testString = "[\u2026]";
HttpUtility.HtmlEncode(testString, writer);
doesn't encode it to be … - it just leaves it as the unicode character (which displays as garbage). It seems like it should work, or there should be a builtin function to do this...
|
|
|
|
|
I have a main form that uses AddOwnedForm to allow these forms to draw on top of the main form.
The problem I am having is with a control that I created by inheriting from System.Windows.Forms.Control.
When I display this control, which belongs to the main form, it will draw properly until it tries to write on top of an area occupied by an owned form.
Is there a way to allow a control to draw on top of anything.
I tried using SetTopLevel but that seems to turn it into a form and puts a forms border around it.
I have seen the build in ComboBox control pop up its listbox over anything so I figure it must be possible.
Does anyone have any ideas?
Thanks,
Jay
|
|
|
|
|
Try overridding the CreateParams property and doing something like so:
protected virtual System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams parms = base.CreateParams;
parms.Style |= WS_POPUP;
return parms;
}
} I'm not totally positive this will work, but it's worth a try.
-----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-----
|
|
|
|
|
Unfortunately that did not work the way I needed. When you modify a control to have the WS_POPUP style it no longer acts as a child on the form and processing of other controls does not work.
Thanks for the suggestion.
|
|
|
|
|
I'm using NetworkStream to read from a TCPClient.
I'm testing DataAvailable before reading to keep by thread from blocking on read.
The docs say that if the remote end has closed the connection, a call to DataAvailable should throw a SocketException, which I canb catch.
Unfortunatly, the exception isn't getting thrown, so my code keeps spinning on DataAvailable forever, never knowing that the connection has been closed. There don't seem to be any other properties or methods in either TCPClient or NetworkStream that I can use to get the connection state without potentially blocking.
Am I missing something? Is there another way to determine if the connection is active without risking a block?
Thanks.
|
|
|
|
|
Most of the TCP code I've done runs in its own thread, so I never worry about blocking. That said, I'll take a few shots at it .
Have you considered the asynchronous version of Read (BeginRead)? It's an asynchronous call, so it's non-blocking.
I once did a simple test application (non-robust) and wanted a Read to timeout after a certain amount of time (this isn't exactly what you want, but keep reading). In order to do this, I needed to get at the Socket itself (TCPClient.Client). Since this property is protected, I ended up having to create my own class (TCPTimeoutClient or some such). Once you get to the actual Socket, you can do all sorts of extra things (take a look at Socket.Available and Socket.Select for instance). I'm not sure if these Socket versions would behave differently, but it might be worth a shot?
I hope some of my babbling might help a little.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Hi C#-people,
I have a ListView, that contains directories and files.
I was wondering how I can popup the context menu (which contains items such as 'open with', 'add to zip', 'Copy', 'Paste', etc...) if I right click on these files/directories.
Can anyone point me in the right direction?
Thanks!
Kind regards
Ludwig
|
|
|
|
|
This is really not as easy as you might hope and - to do so in C# - will require recreating countless interfaces, enum, structs, and consts already defined in various headers for Win32 shell programming.
See my answer to a somewhat similar problem to an early question today: http://www.codeproject.com/script/comments/forums.asp?msg=669971&forumid=1649#xx669971xx[^]
While this isn't exactly what you're looking for, you're now going to have to play the part of the Windows shell and pass an ITEMIDLIST - which is going to be hard enough in an application that knows little about the actual shell - to a default context menu while accessing the registry to query for other context menu handlers for the associated file type. I give several links in that previous post. You should read the documentation at the targets of those links about shell programming. There's a lot involved so you might consider just handling generic operations like copy, cut, and paste (if they represent real files, you can simply use the DragDropFormats.Files clipboard format and put a string[] array of filenames into the DataObject for the drag-n-drop or clipboard operation like cut and copy (using the appropriate DragDropEffects ). That clipboard format is one the shell recognizes and will cut or copy the files appropriately.
-----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-----
|
|
|
|
|
Hi all.
I need to get internet expl. selected text to process in my C# application.
Any clear help will be appreciated.
|
|
|
|
|
Get the IHTMLDocument2 interface from the WebBrowser control (include the Microsoft.mshtml assembly in your project and get it from the WebBrowser.Document property, which may be null), then get the selection property (which may be null). This gets an IHTMLSelectionObject from which you can use the type property to determine the selection type (text, insertion point, control, etc.) and the createRange method to create a suitable object to work with the actual selection (like a TextRange ). See the documentation for IHTMLSelectionObject in the MSDN Library for more detailed information).
-----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-----
|
|
|
|
|
Ughhh ugly and messy COM interfaces. Can't wait for Whidbey's managed web browser control.
The graveyards are filled with indispensible men.
|
|
|
|
|
I haven't had a time to look at it (or eat, or drink, or breathe) lately. Is the WebBrowser control completely managed (inside and out), or is it just a nicer CCW for the existing WebBrowser COM control (wrapping mshtml and providing IHLink and all that jazz)?
I know our app would definitely benefit from that, especially when the Microsoft.mshtml.dll assembly is almost 8 MB!
-----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 didnt understand what you tried to tell.
What web browser? Do i have to create mine in order to get the selected text?
Say there is an instance of ie open , after that my app is run , and typing a hotkey I see the selected text. I want this.
|
|
|
|
|
"IE" as you call it is nothing more than an application that hosts the WebBrowser control (which hosts MSHTML). Read the documentation for the Internet Explorer SDK. Read information specifically about IHTMLDocument2 and its selection property. If you don't understand how to get the IHTMLDocument2 object, there are plenty of articles here on CP about it. Just search for "WebBrowser" or "IHTMLDocument2".
-----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-----
|
|
|
|
|
Hi,
I create in the folder DEBUG or RELEASE some settings files for my executable.
When I compile my project, the compiler delete the settings files and recreate a new folder DEBUG or RELEASE with the compiled files
So how can I do for disable this option.
Best Regards
youssef
|
|
|
|
|
What do you mean by "settings file"? Do you mean the .config file? If this is the case, remove the app.config file from your project, which is a specially named file that's name is changed and it is copied to the output directory. Usually this is desired behavior so that you can source-manage the configuration file.
Otherwise, you may have a pre- or post-build configuration (only in VS.NET 2003 and up for C# and VB.NET) that is deleting these files because the project compilers only replace files in the output directories that it actually creates.
-----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-----
|
|
|
|
|
Hello.
I'm using an ActiveX Control in my .NET project and I have to use a method that originally accepted a IStream.
The .NET type library importer has modified the parameter of this method and now looks like this Interop::MyActiveXControl::IStream.
The problem that I have is that I can't create directly a Interop::MyActiveXControl::IStream because this is an interface.
I have created a System::IO::MemoryStream and fill it with data but this type can't be converted ( or I don't know how ) to convert to Interop::MyActiveXControl::IStream.
Any ideas ??
Thanks in advance.
|
|
|
|
|
Create a new class and implement that interface. There won't be a class generated for it because the parameter is an interface, unless your COM library exposed a class that already implements it elsewhere.
-----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 wrote an application a while back that used WIN32 C++ to query a list box in another application for its contents (using SendMessage).
I would like to do the same in C#, but instead of using SendMessage, I would like to associate the HWND with a ListBox instance.
I can get the HWND for the listbox that is in another app, and I tried using Control.FromHandle, but it returns null. If, however, I put a listbox in my own application it works. This made me suspect that it is a security issue and just not possible.
Thanks for any help.
|
|
|
|
|
An HWND is not global but specific for an application's domain. (It's essentially a pointer). It is therefore not possible to use an HWND outside of that application.
|
|
|
|