|
Hello,
Here is the code.
string strWapiServer = "\\\\" + txtServerName.Text;
ConnectionOptions options = new ConnectionOptions();
options.Username = "username";
options.Password = "password";
//options.Authority = "NTLMDOMAIN:myDomainName";
ManagementScope myScope = new ManagementScope(strWapiServer + "\\root\\cimv2", options);
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN32_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
//Iterate through printers...
foreach (ManagementObject oItem in oResults.Get())
{
string strPrinterName = oItem.Properties["DeviceID"].Value.ToString();
}
}
|
|
|
|
|
I'm guessing here, mind you, but I think you may be using an inappropriate constructor for your ManagementScope. The path-as-string you are using may not be valid in the 64-bit OS. Here is the link to the constructor that uses a ManagementPath object instead of a string, which I think may help you get to where you want to be:
http://msdn.microsoft.com/en-us/library/ms143590.aspx[^]
|
|
|
|
|
I still get the access denied and it seems it is definitely a permissino issue.
I have to figure out what this permission is and where.
Thanks anyway.
|
|
|
|
|
Actually I have encountered several problems working with Word.
Please see if you can help me resolve them.
My application creates documents (Microsoft.Interop.Word.Document) each one according to another template(.dot on the hard disc). Then I have to merge them and save as a single .doc (while the original formatting is saved). I do this in the following way:
Range rangeTrg = ((Document)(m_WordDocsArr[0])).Content;
object brk = WdBreakType.wdSectionBreakNextPage;
object rngEnd = WdCollapseDirection.wdCollapseEnd;
rangeTrg.Collapse(ref rngEnd);
for (int i = 1; i < m_WordDocsArr.Count; i++)
{
rangeTrg.InsertBreak(ref brk);
Range rangeSrc = ((Document)(m_WordDocsArr[i])).Content;
rangeTrg.FormattedText = rangeSrc.FormattedText;
rangeTrg.Collapse(ref rngEnd);
}
Problem #1:
If there is one document in m_WordDocsArr, afterwords when I open the .doc by doubleclicking it, Word opens it in Print Layout, if there is more than one document in m_WordDocsArr, Word opens it in Normal layout.
Why?
Problem #2:
The original templates I use have headers and footers.
Somewhy (???) the merged doc has the first document's headers and footers.
I tryed to save the headers and footers of the original docs before merging and assign them afterwords to each section, but the following code throws the exception:
ArrayList footers = new ArrayList();
....
footers.Add(((Document)(m_WordDocsArr[i])).Sections.First.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.FormattedText);
.....
int ih = 0;
foreach (Section sec in ((Document)(m_WordDocsArr[0])).Sections)
{
sec.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].LinkToPrevious = false;
sec.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.FormattedText = ((Range)footers[ih]).Duplicate;
ih++;
}
<pre>
So it is not so trivial for me to merge the documents with their original formatting?????
Please help me !!!???
Thanks.
:confused::confused:
<div class="ForumMod">modified on Tuesday, September 23, 2008 8:43 AM</div>
|
|
|
|
|
The original is here[^].
Please don't attempt to bump a post - it's bad form.
|
|
|
|
|
Oh Lordy, another one of those post bumps...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I would like to write some lines to the file from the beginning preserving the old contents of the file in C#.
For example my file contains
One
Two
Three
i want to add one line in the beginning like the following
New Line
One
Two
Three.
One possible solution is copying the whole content of the old file in to other file, and write the new line and append the old content. Is there any other possible ways?
Please let me know if anyone knows the answer.
|
|
|
|
|
mutpan wrote: One possible solution is copying the whole content of the old file in to other file, and write the new line and append the old content.
That is the correct way, unless you want to pull out all your hair and break stuff around the office
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Write to a temporary file and then move/rename it to the orignal.
|
|
|
|
|
mutpan wrote: One possible solution is copying the whole content of the old file in to other file, and write the new line and append the old content. Is there any other possible ways?
In Windows, that is the only solution. Some operating systems have file systems that allow insertion of records at points within the file other than the end, but none of the common file systems for Windows allow that.
|
|
|
|
|
Hi,
How can i denay the Screen.PrimaryScreen.Bounds.X function which take the screen short of the desktop.
Can any windows settion..or can i write another program..
Thankyou,
Ypki
|
|
|
|
|
ypki wrote: denay
I realise you are not an English speaker, but I do not understand that word
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
|
Hi,
If the string is of any length(like 1 or 20), need to encrypt this string to 10 char length.
Please help me
Thannks
Sri
|
|
|
|
|
How can 20 chars fit into 10 chars? I think you need to re-read your problem/task again.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
|
Huh?
Huffman
a) is not an encryption method, but rather a compression method (entropy encoding to be precise)
b) does not guarantee compression sizes of 50% (20 chars to 10)
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thus the " "
|
|
|
|
|
Plot File content is ->ABCDEFGH
i used drawline() method in c# to draw all drawings, but labels are not displayed properly.its showing reverse format->HGFEDCBA
i read file format but i couldn't find any answer.please tell me how to handle lables in HPGL Plot files.
modified on Tuesday, September 23, 2008 11:23 AM
|
|
|
|
|
Hello,
I need to create a utility(desktop application in C# .net) to track all the website URL's that been used.
Thanks in advance,
ULLAS K
|
|
|
|
|
ullas.koravangatt wrote: I need to create a utility(desktop application in C# .net) to track all the website URL's that been used
Excellent. So you've got your high level user requirements. Good luck with the design. Or was there meant to be a question in there?
If you're asking for help with the algorithms, you are in the wrong forum - you should target the Design forum instead.
|
|
|
|
|
Hello,
For that I am using an interop.shdocvw.dll but it be tracks only IE instances not the other browsers. So this is my question that how can i get the all instances of other browsers like mozilla, google chrome etc.
Thanks
ULLAS K
|
|
|
|
|
Listen to the port instead. Your normal web requests go through port 80.
|
|
|
|
|
Hello,
For that Am using "SNIFFER" programming. But Am not expert in that case. If you have any reference site or any thing please inform me.
Thaks,
ULLAS K
|
|
|
|
|
ullas.koravangatt wrote: I need to create a utility(desktop application in C# .net) to track all the website URL's that been used.
What URLs? used by what? Is this for a browser session, or a web server?
|
|
|
|