|
If you want the code, Google for it! Here, it's this[^] easy.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thanks very mutch... but i cann't find IMPLEMENTATION CODE for this algorithm
|
|
|
|
|
Well, it looks like you're going to have to write your own code! (Gasp!)
You didn't happen to see the pseudo-code at the end of a few of those PDF documents, did you?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Tell Explorer to Reload Display Registry Settings?
I have been looking everywhere for a simple example on how to make a change to the HKCU\Control Panel\Desktop registry keys and then have Explorer or Desk.cpl or whatever, reload it back into memory.
I've found stuff that looked promising, but I could never make it work.
I thought that this would be it but it's not but I know it's the right track:
[DllImport("user32.dll",<br />
CharSet=CharSet.Auto, SetLastError=true)]<br />
[return:MarshalAs(UnmanagedType.Bool)]<br />
public static extern bool<br />
SendMessageTimeout(<br />
IntPtr hWnd,<br />
int Msg,<br />
int wParam,<br />
string lParam,<br />
int fuFlags,<br />
int uTimeout,<br />
int lpdwResult<br />
);<br />
<br />
public const int HWND_BROADCAST = 0xffff;<br />
public const int WM_SETTINGCHANGE = 0x001A;<br />
public const int SMTO_NORMAL = 0x0000;<br />
public const int SMTO_BLOCK = 0x0001;<br />
public const int SMTO_ABORTIFHUNG = 0x0002;<br />
public const int SMTO_NOTIMEOUTIFNOTHUNG = 0x0008;<br />
<br />
<br />
int result;<br />
SendMessageTimeout( (System.IntPtr)HWND_BROADCAST,<br />
WM_SETTINGCHANGE,0,"Environment",SMTO_BLOCK | SMTO_ABORTIFHUNG |<br />
SMTO_NOTIMEOUTIFNOTHUNG, SomeTimeoutValue, out result);
I just want to broadcast to all Windows that a registry change was made and that they need to reload their section.
|
|
|
|
|
I am trying to find a way to run a java program from within a C# program using the following;
java -Xmx1000M -jar odljava.jar
Followed by a filename that may or may not contain wildcards e.g. filename*
I have tried using myProcec= Process.Start(java -Xmx1000M -jar odljava.jar) but with no luck.
Anyone know how to do this?
David Wilkes
|
|
|
|
|
instead of passing all the arguments in process.Start, have you tried created a new Process instance, then setting the process' .StartInfo.Arguments property to the "-Xmx1000M -jar odljava.jar" arguments?
|
|
|
|
|
hi friends
what is the difference between
console.readline();
vs
console.read();
regards
saravanan
|
|
|
|
|
Console.Read Method[^]
Reads the next character from the standard input stream.
Console.ReadLine Method [^]
Reads the next line of characters from the standard input stream.
Difference:
"line of ... ers"
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Im trying to write a utility that opens an excel file using C#.net Visual Studio 2005. One of the first things I have to do is add a reference to the Microsoft Excel 11 Object Library. After I add this I have to add the "using" statement to use Microsoft.Office.Interop.Excel. However, I cant seem to be able to find the Interop class. Intellisense only picks up Microsoft.Office.Core ...has anyone else experienced this? How did you add this class?
Thanks
|
|
|
|
|
Your using statement will be
using Microsoft.Office.Core;
Just because I've been through this pain before and the documentation for automatation is awful, I thought I'd paste an old demo I had lying around...
private void ReadExcelValue()
{
object o = System.Reflection.Missing.Value;
Excel.Application objE = new Excel.Application();
Excel.Workbooks objBooks = null;
Excel.Workbook objB = null;
Excel.Worksheet objS = null;
objE.Workbooks.Open(Server.MapPath("spreadsheet.xls"), o, o, o, o, o, o, o, o, o, o, o, o, o, o);
objBooks = objE.Workbooks;
objB = objBooks[(object)1];
objS = (Excel.Worksheet)objB.Worksheets[(object)1];
Response.Write(((Excel.Range)objS.Cells[1, 1]).Text);
Release(objS);
if (objB != null)
objB.Close(false, o, o);
Release(objB);
if (objBooks != null)
objBooks.Close();
Release(objBooks);
if (objE != null)
objE.Quit();
Release(objE);
GC.Collect();
System.Diagnostics.Process[] objPr = System.Diagnostics.Process.GetProcessesByName("Excel");
foreach (System.Diagnostics.Process pr in objPr)
pr.Kill();
}
private void Release(object obj)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
}
catch { }
finally
{
obj = null;
}
}
Note: It's rather ugly stuff and there's a cheesy hack to make sure that the excel process doesn't persist on the server after execution (yes it's pretty easy to end up with thousands of Excel.exe processes if you don't kill them).
HTH
|
|
|
|
|
am i still missing any namespaces apart from the Microsoft.Office.Core library? cause I dont have the Application or Workbook classes in the Excel library (maybe im not stating that correctly). When I type Excel. intellisense does not pick up Application or Workbook...do I need any thing else?
Thanks
|
|
|
|
|
I only had two references I added to get that code working were:
Microsoft Office 11.0 Object Library
Microsoft Excel 11.0 Object Library
Obviously those will vary dependant on which version of office you are developing against.
Intellisense partially works in web developer express, and vs 2005. I do seem to remember that it pretty much didn't work at all in older versions of visual studio (but not 100% sure on that). It's all part of the pain of doing office automation I'm afraid
HTH
|
|
|
|
|
i cant even compile the project let alone get intellisense to work. i think im missing some namespace...the pain with VS 2005.
im waiving the white flag..help.
|
|
|
|
|
Have you included the Microsoft Interop Assemblies as references in your project?
|
|
|
|
|
I did do an add reference, and the on the COM tab chose Microsoft Excel 10 Object Library.
Does this suffice? Do you have to manually install any other interop libraries?
|
|
|
|
|
I believe that should be sufficient. You might, however, need the Excel 11 libraries, which are included on the install disk for excel if you have 2003 or 2003 Pro (But NOT 2003 basic).
Once you have the right one included, you should be able to access the correct namespaces/methods.
|
|
|
|
|
I have a user control with a ListView on the top and two buttons on the lower left. As the control is resized, I want the list to "grow" and the buttons to stay at the lower right. The ListView is anchored to top, bottom, left, right and the buttons are anchored to bottom and right. I can change the size at design time and everything works as planned. When I drop this on a form and drag the size to the size I want, it works fine. But when I close the designer and reopen it, it appears the ListView has expanded to the full size of the control like it is docked to each edge. Any idea what may be wrong?
I also tried setting the size in code but same issue at runtime.
Thanks. -- Bud
|
|
|
|
|
|
I have written app, borrowing some code from this article ( http://www.codeproject.com/cs/miscctrl/MyExtRichTextBox.asp?df=100&forumid=229962&select=1556581&msg=1556581[^] ). I have controls being inserted at various locations throughout a document and everything looks great. I'm able to query the interface and iterate through each control in the document. Great.
Now, however, I have to be able to save the document to be reloaded at a later time in the same application. When I do this normally, I lose the control information.
So, how can I save the document so that when I reload it, my controls are still showing up in the richtextbox?
Any help is greatly appreciated.
Thanks,
Tony
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
When I look at the rtf, each place a control should be I have this:
\objattph\'20
So, something is being saved. However, there are properties on each control that are unique for each control inserted. I need to persist this data.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
Hi!
What are you using to save/load the contents of the RTB?
I just tried pasting an OLE object into the RTB, then saving it via RichTextBox.SaveFile() . Re-loading it afterwards with RichTextBox.LoadFile() showed the object...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Well, I'm not using an OLE object (which is the most likely reason why this doesn't work), I'm using a control I created in VS 2003. I'm fairly certain that if I implement the correct interfaces in the control that it will save correctly. But, I wouldn't swear to it.
I've tried the save file, I've even tried streaming it straight to disk. The objects are there because I can (using IRichEditOle.GetObjectCount) get a correct count of objects, and actually get the objects back, cast them to the appropriate control and access their properties. This is all before saving though. Once saved, it seems that only a placeholder is saved, and not the object or it's data.
Any ideas on what ole interfaces need to be implemented? Any Examples would be appreciated as well. I can't seem to find a lot of information about this.
Thanks,
Tony
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
Any help is appreciated.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
I have a listbox with a contextmenu. The contextmenu has items such as "add" and "move up" and "move down" and "delete".
But how do I get the listboxitem that were clicked and hence the 'object' for the actions? It's not the selected item on the listbox since I right clicked to get the contextmenu.
I have a feeling that this should be easy, but I just dont know how to do it.
|
|
|
|
|
iakob wrote: But how do I get the listboxitem that were clicked
They hide that information in the documentation[^]
led mike
|
|
|
|