|
use : SystemColors.Highlight
thats the bg color (usually dark blue)
//Roger
|
|
|
|
|
This must be so basic a need that everyone knows it, yet I cannot find a reference anywhere.
I want to programmatically from C# bring up the 'default" defined web browser and point it at a particular URL.
Can someone point me to a URL with a reference?
Thanks
-Adrian
|
|
|
|
|
The default web browser is governed by a registry entry.
I think the registry key is
HKEY_CLASSES_ROOT\http\shell\open\command
so you read the above key and launch the application with the url as a command line argument.
I hope this should work
If you need more information, have a look at the below URL
http://help.netscape.com/kb/consumer/19980502-2.html[^]
Cheers
Kannan
|
|
|
|
|
What I do in Desktop Bob[^] is:
System.Diagnostics.Process.Start(sURL)
But this has some issues I describe at the end of the article.
I see dumb people
|
|
|
|
|
Thanks - the Process.Start(sUrl) stuff did it for me.
|
|
|
|
|
I have created a service in c#.
And I am executing a Process.Start command in this code ( OF SERVICE PROJECT) .
that command(Process.Start ) is executing sucessfully for local drives but it throws Win32Exception (means There was an error in opening the associated file) at network path. for example path is \\computername\folder1\folder2\some.exe
AND it heapens only with Service type application all other applications are executing any process at network path (i.e \\computername\folder1\folder2\some.exe)successfully with this command(Process.Start).
Can any body tell how will I make my Service to execute any Process at network path?
plzzzzzzz help me?
r00d0034@yahoo.com
|
|
|
|
|
What context is your service running in?
Perhaps this is a security issue.
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
|
|
|
|
|
i also think that it is a security issue.
but question is this when i run my application(that is not a service program) at that computer with same user it successfully execute the process (at network path).
i have a simple network of two computers.i am sharing internet on it too.
both have os xp_prof installed on it.
i have created a user on both machine with same user name and password.and that user is member of admin.. group.
under this account i am running my service.
and my service related code is this.
if you want too see any other part of my program plz tell and solve my problem
i will be very thank full to you.
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
namespace WinService1
{
[RunInstaller(true)]
public class ProjectInstaller : System.Configuration.Install.Installer
{
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller;
private System.ServiceProcess.ServiceInstaller serviceInstaller;
public ProjectInstaller()
{
InitializeComponent();
}
#region Component Designer generated code
private void InitializeComponent()
{
this.serviceProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller = new System.ServiceProcess.ServiceInstaller();
this.serviceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller.Password = null;
this.serviceProcessInstaller.Username = null;
this.serviceInstaller.DisplayName = "Cient service running on server";
this.serviceInstaller.ServiceName = "Service";
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller,
this.serviceInstaller});
}
#endregion
}
}
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
using WinTCP;
using Threads_for_Installation;
using CSharp.Mok.WinSocket;
using System.Windows.Forms;
using System.IO;
namespace WinService1
{
public class Service : System.ServiceProcess.ServiceBase
{
private System.ComponentModel.Container components = null;
private Entertainer Obj;
private enum DateType
{
Local = 128, UTC = 129
}
public Service()
{
InitializeComponent();
}
static void Main()
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
private void InitializeComponent()
{
this.ServiceName = "Service";
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
protected override void OnStart(string[] args)
{
Directory.CreateDirectory("myNewDirectory");
Obj=new Entertainer();
}
protected override void OnStop()
{
Obj.Closing_Thread();
}
protected override void OnCustomCommand(int command)
{
switch (command)
{
case (int) DateType.Local:
break;
case (int) DateType.UTC:
break;
}
}
}
}
r00d0034@yahoo.com
|
|
|
|
|
I don't know if you'll still be reading this but I have to answer this in any case.
Does your service try to access any desktop resources. Services are typically not allowed to interact with the desktop. I haven't studied your code but it uses System.Windows.Forms so it might try to access the desktop.
|
|
|
|
|
yes it inteacts with desktop for that purpose
i right click my service and in logon tab i have select a check box which allow me to interacts with desktop.
plzzz help me?
r00d0034@yahoo.com
|
|
|
|
|
OK, you have two problems here:
1) Services running under a user account can not interact with the desktop since this can lead to elevation of privilege. So to interact with the desktop, the service needs to run as the local system account.
2) The local system account does not have access to any network resources and that's why you're getting the error.
It's a tough call on how to fix this. The easiest way would be to remove any interaction with the desktop from the service. Put the desktop code into a seperate application that is launched by the user that is logged in. Have that application communicate with the service somehow to let the service know what it should do.
An example of this is an AntiVirus application. The service is seperate from the application used to control the service. They are actually two seperate .exe files. The controlling application sets some registry settings (for example) which the service polls.
|
|
|
|
|
All,
I have a DataGrid populated with rows. When I click the "child" rows, it displays the next level. At the top right of the grid, it displays two buttons - one with an arrow ("Navigates back to the parent rows") and one with a rectangle above a set of arrows("Shows/hides the parent rows for the current set of child rows"). So, this is pretty much a "standard" situation. Given this, how can I keep the second button from appearing in the upper right. I only want the first one with an arrow to be displayed or I'd like to be able to cancel the ShowParentDetailsButtonClick. Does anyone have any ideas?
Thanks,
RB
|
|
|
|
|
Ok, I am trying to make an Expression to evaluate a Short Time format (hh:mm). I've seen the standard format of "\d\d:\d\d" but I can't use it because it allows values greater than 23 for the Hour.
I've come up with one but I need help on the 2nd digit in the hour. Basically in laymen's terms it goes something like this: (1 or 2)(??):(0 - 5)(0 - 9). The Regular Expression looks like this: "[1,2](Nothing here??):[0-5]\d".
Here's what I need to do. If the first Digit is a "1", then the 2nd digit can be "\d" or "[0-9]" (for hours 0 - 19) . Otherwise, if the first digit is "2", then the 2nd digit can only be "[0-3]" (for hours to 20 - 23).
Can anyone help?
|
|
|
|
|
Try this:
^(?<hour>\d|([0-1]\d)|(2[0-3]))<span>:</span>(?<min>[0-5]\d)$
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
If you really want to do all the error checking in the regular expression for Short Time format, try this:
^(([01]?\d)|(2[0-3])):[0-5]\d$
Or more explicitly:
^(([01]?[0-9])|([2][0-3])) 0-5][0-9])$
If you don't want to allow h:mm times, take out the ?.
|
|
|
|
|
Hi there...
Does anyone know how to get a picture from Excel in C#?
(The picture is pasted into a worksheet.)
Thanks in advance,
Michel van Meijer
|
|
|
|
|
Start with the VBA macro recorder in Excel, and record this. Then check out the resulting code, and translate the object model calls to C# : should be straight forward if you use the excel interop assemblies (mapping of names).
|
|
|
|
|
Thanks! That indead was a smart idea! Never thought of that...
Although I could get to the Excel.Shape but I have no clue on how to transform it to a Image. A can't simply typecast it.
In case you can help: thanks again.
|
|
|
|
|
mvmeijer wrote:
Although I could get to the Excel.Shape but I have no clue on how to transform it to a Image. A can't simply typecast it.
What you want to do is unclear.
Phase one was to get the right method call keywords. With that in hands, now you can fire Google and get your code snippet.
[edit]You've got stuff like this[^] for instance.[/edit]
Good luck!
|
|
|
|
|
The solution is (took me a lot of time to find out myself):
(ws = an Excel.Worksheet, index = Worksheet number)
Excel.Shape shape = ws.Shapes.Item(index);
Excel.Picture p = (Excel.Picture) shape.DrawingObject;
p.CopyPicture(Excel.XlPictureAppearance.xlScreen, Excel.XlCopyPictureFormat.xlBitmap);
if (shape.Type == Microsoft.Office.Core.MsoShapeType.msoPicture) {
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Bitmap)) {
Bitmap b = (Bitmap) data.GetData(DataFormats.Bitmap);
// Do something with the Bitmap
}
}
|
|
|
|
|
Hey this is neat! Congrats. I hope people answering on Cp will refer to this code anytime someone asks this question over and over again.
|
|
|
|
|
|
|
|