|
1- Check for the registry key HKEY_LOCAL_MACHINE\Software\Microsoft\Office , if this exists then MS Office is installed in the system or you can check if WINWORD.EXE file exists.
2- For wordpad check WordPad.exe .
3- Same approach you can use for open office, for Open office there must by some executable file.
WWW, WCF, WWF, WPF, WFC .... WTF
|
|
|
|
|
I am using this code to open an adobe reader document but I want to know how can I set the start size to maximized?
Process.Start(Application.StartupPath + "\\Bahrain2030_English.pdf");
|
|
|
|
|
Based on the following, it doesn't seem like you've got anything provided via command arguments (Adobe Reader[^]).
It looks like you'll have to find the reader process and using pinvokes (like this[^]) to maximize the window.
|
|
|
|
|
try something in this format:
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(Application.ExecutablePath + "\\Bahrain2030_English.pdf");
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
System.Diagnostics.Process.Start(info);
|
|
|
|
|
I am uisng this code to read a specific node from XML using XMLDocument but I want to use the Dataset.ReadXML and want to know how can I do the same but using Dataset?
Save the Value to XML:
resume_xml_document.SelectSingleNode("/Resume/Detail/FullName").InnerText = PersonalInfoForm.txtFullName.Text;
Getting the Value from XML:
txtFullName.Text = resume_xml_document.SelectSingleNode("/Resume/Detail/FullName").InnerText;
|
|
|
|
|
Greetings, all...
I'm using Visual Studio 2008 Express with C# and SQL Server 2008 backend. I'm wanting to design a lookup table form where the user can select the table from a list of items on the left (probably a TreeView with a node for each entry), then have the grid on the right reflect the contents of that table (Users, Config settings, Security, etc.). But I don't have to have a table adapter for each table that could be on the form and would like to re-use the component by setting the properties on the fly. Has anyone done this before?
As a corrolary to this, if the user double-clicks on an entry in the grid, I would like to pop-up a form to allow the user to edit that entry. Again, I would like to use a single form to do this, without having a different form and table adapter, binding source, etc., for each possible table.
Has anyone done this before and can offer any suggestions? Or would the code to do it all run-time outweigh what it would take to just have separate table adapters and forms for each possible lookup table?
Thanks in advance!
- Bert
|
|
|
|
|
Hi all,
I'm trying to expand the code here:
http://www.fryan0911.com/2009/05/how-to-read-pop3-email-using-c.html[^]
so that previosly read messages aren't read over again. I thought I could make this work by storing previosly read messages Id's in a text file and compare these Ids to the message Ids retrieved from the server. The problem I'm having is when trying to assign a message id to the sLine variable as you can see below:
StreamReader objReader = new StreamReader(readIDPath + "readIDs");
POPMessageId sLine;
int i = 0;
while (objReader != null)
{
sLine = objReader.ReadLine();
if (sLine != null)
{
readIDs[i] = sLine;
i++;
}
}
objReader.Close();
The error I get is:
Error: Cannot convert type 'string' to 'SmtPop.POPMessageId'
I've tried casting the string to type POPMessageId but that doesn't fix it. Is there a way I can store the Id's in the file as type PopMessageId or retrieve them as this type? I'm new to working with files in C# but I'm sure it must be possible.
Hope you can help.
Mel
|
|
|
|
|
Of course you're getting an error, a string is not a POPMessageId nor vise versa.
What is POPMessageId? (No, I'm not downloading the library to find out)
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for your reply Mark.
I looked at the POPMessageId and it takes in two ints (Id & size):
POPMessageId(Int Id, Int size)
This helped me resolve my problem as I then just converted the string taken from the text file to type Int32 and added it to the Id of my sLine POPMessageId object.
sLine.Id = Convert.ToInt32(objReader.ReadLine());
Since opening this thread I was able to complete what I set out to do, which was to keep track of previously read emails on a POP3 server.
I could have used:
http://www.example-code.com/csharp/pop3_unread.asp[^]
but I wanted to give this a shot myself. Plus I didn't like the "30-day trial"
Thanks again
Mel
|
|
|
|
|
Glad it helped point you in the right direction.
Now to find the moron who voted 1
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Well I just voted it as a good answer.
Hope that brings the score up a little.
Thanks again
|
|
|
|
|
Hi,
I am trying to build an IE BHO in C# for taking the snapshot of a webpage loaded in the IE browser. Here is what I'm trying to do:
public class ShowToolbarBHO : BandObjectLib.IObjectWithSite
{
IWebBrowser2 webBrowser = null;
public void SetSite (Object site)
{
.......
if (site != null)
{
......
webBrowser = (IWebBrowser2)site;
......
}
}
}
Also, I p/invoke the following COM methods:
[Guid("0000010D-0000-0000-C000-000000000046")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
[ComImportAttribute()]
public interface IViewObject
{
void Draw([MarshalAs(UnmanagedType.U4)] int dwDrawAspect, int lindex, IntPtr pvAspect, [In] IntPtr ptd, IntPtr hdcTargetDev, IntPtr hdcDraw, [MarshalAs(UnmanagedType.LPStruct)] ref COMRECT lprcBounds, [In] IntPtr lprcWBounds, IntPtr pfnContinue, int dwContinue);
int GetColorSet([MarshalAs(UnmanagedType.U4)] int dwDrawAspect, int lindex, IntPtr pvAspect, [In] IntPtr ptd, IntPtr hicTargetDev, [Out] IntPtr ppColorSet);
int Freeze([MarshalAs(UnmanagedType.U4)] int dwDrawAspect, int lindex, IntPtr pvAspect, out IntPtr pdwFreeze);
int Unfreeze([MarshalAs(UnmanagedType.U4)] int dwFreeze);
int SetAdvise([MarshalAs(UnmanagedType.U4)] int aspects, [MarshalAs(UnmanagedType.U4)] int advf, [MarshalAs(UnmanagedType.Interface)] IAdviseSink pAdvSink);
void GetAdvise([MarshalAs(UnmanagedType.LPArray)] out int[] paspects, [MarshalAs(UnmanagedType.LPArray)] out int[] advf, [MarshalAs(UnmanagedType.LPArray)] out IAdviseSink[] pAdvSink);
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public class COMRECT
{
public int left;
public int top;
public int right;
public int bottom;
public COMRECT()
{
}
public COMRECT(int left, int top, int right, int bottom)
{
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
}
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
[ComVisibleAttribute(true)]
[GuidAttribute("0000010F-0000-0000-C000-000000000046")]
[ComImportAttribute()]
public interface IAdviseSink
{
void OnDataChange([In]IntPtr pFormatetc, [In]IntPtr pStgmed);
void OnViewChange([MarshalAs(UnmanagedType.U4)] int dwAspect, [MarshalAs(UnmanagedType.I4)] int lindex);
void OnRename([MarshalAs(UnmanagedType.Interface)] object pmk);
void OnSave();
void OnClose();
}
Now When I take the snapshot:
I make a call CaptureWebScreenImage((IHTMLDocument2) webBrowser.document);
public static Image CaptureWebScreenImage(IHTMLDocument2 myDoc) {
int heightsize = (int)getDocumentAttribute(myDoc, "scrollHeight");
int widthsize = (int)getDocumentAttribute(myDoc, "scrollWidth");
Bitmap finalImage = new Bitmap(widthsize, heightsize);
Graphics gFinal = Graphics.FromImage(finalImage);
COMRECT rect = new COMRECT();
rect.left = 0;
rect.top = 0;
rect.right = widthsize;
rect.bottom = heightsize;
IntPtr hDC = gFinal.GetHdc();
IViewObject vO = myDoc as IViewObject;
vO.Draw(1, -1, (IntPtr)0, (IntPtr)0, (IntPtr)0, (IntPtr)hDC, ref rect, (IntPtr)0, (IntPtr)0, 0);
gFinal.ReleaseHdc();
gFinal.Dispose();
return finalImage;
}
I am not getting the image of the webpage. Rather I am getting an image with black background. I am not sure if this is the right way of doing it, but I found over the web that IViewObject::Draw method is used for taking the image of a webpage in IE.
I was earlier doing the image capture using the Native PrintWindow() method as mentioned in the following codeproject's page - http://www.codeproject.com/KB/graphics/IECapture.aspx
But the image size is humongous! I was trying to see if I can reduce the size by using other techniques. It would be great if someone can point out the mistakes (I am sure there would be many) in my code above.
Thanks, Kapil
|
|
|
|
|
hello, i need help with my project for college, i am using visual studio 2008 and c# programming lang.
I want to grab the file name or file path to put into a rich text document using an openfiledialog.
Users are able to select the file using the openfiledialog, select the file, and then when they double click or press open, the file name is inserted into the richtextbox.... to insert the text i am using InsertText("");
thanks
|
|
|
|
|
And what is the problem that you are having?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
You can use OpenFileDialog:
OpenFileDialog sfd = new OpenFileDialog();
sfd.Filter = filterString;
if (sfd.ShowDialog() == DialogResult.OK)
{
string fileName = sfd.FileName;
...
}
or FolderBrowserDialog:
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.SelectedPath = tbInitialDir.Text;
if (fbd.ShowDialog() == DialogResult.OK)
{
string filePath = fbd.SelectedPath;
...
}
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Thanks for the code example, can u tell me another thing which is how i would put the string / filename into a rich text box ? thanks again ..
modified on Monday, March 29, 2010 3:52 PM
|
|
|
|
|
Didn't you say you were using InsertText()?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
yeah like inserttext("hello") , but i don't know how to put it for a string .... is it like inserttext("string filename"); or ?
|
|
|
|
|
SRJ92 wrote: but i don't know how to put it for a string
What do you think "hello" is?
You get a string for the filepath back from the OpenFileDialog. You just put that string in the InsertText call. What's the problem?
|
|
|
|
|
sorry i found out now, lol just me being dumb and not thinking right... thanks ...
|
|
|
|
|
I need to substitute the ups rate calculation codes.
I can't find in C#.
does anybody have??
|
|
|
|
|
AFAIK UPS does not publish this information. They want you to use their services.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
I am using this code to send email through Gmailand everything was fine until recently.. I am now getting this error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
What's the problem?!!
This is is code I was using for long time already:
NetworkCredential loginInfo = new NetworkCredential(gMailAccount, password);
MailMessage msg = new MailMessage();
msg.Sender = new MailAddress(from, displayname);
msg.ReplyTo = new MailAddress(from, displayname);
msg.From = new MailAddress(from, displayname);
msg.To.Add(new MailAddress(to, "Jassim Rahma"));
msg.Subject = subject;
message = message.Replace(@"\r\n", Environment.NewLine);
msg.Body = message;
msg.Priority = MailPriority.High;
msg.IsBodyHtml = true;
Attachment mail_attachment = new Attachment(Application.StartupPath + "\\rbuilder.log");
if (technical_data == true)
{
msg.Attachments.Add(mail_attachment);
}
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.Port = 587;
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = loginInfo;
client.Send(msg);
MessageBox.Show("Thank you." +Environment.NewLine + Environment.NewLine + "Your email was receieved.", "Feedback", MessageBoxButtons.OK, MessageBoxIcon.Information);
return true;
|
|
|
|
|
I found this information[^] on the GMail site.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|