|
workround:
If I sort from code I have a work round to add the images again after DatagridView.Sort() but if a user sorts by clicking then I need a event like 'AfterSort' or something which doesn't seem to exist ...
...
°°°°°°°°°°°°°°°°°°°°°°°
-- Inter Access Belgium --
|
|
|
|
|
Hello,
I am working on using a COM from C++ in new C# code. I have connected and I can get access to the member functions. The problem that I am having is that one of the member functions takes a STRUCT as an input and it outputs an array of STRUCT. And in the STRUCT there are some char arrays. So when I run the C# code I get an error message "Specified array was not of the expected type."
I'll put in a bit of the code that I am converting:
C++
-----------------
interface IHangerAssignment2 : public IUnknown
{
virtual HRESULT STDMETHODCALLTYPE Analyze(const HangerIn2& rIn, HangerOut2* pOut, int nOut, int& nResults) = 0;
};
where HangerIn2 and HangerOut2 are structs that inherit from other structs. HangerOut2 inherits from a struct that contains 2 char arrays. HangerOut2 also contains an array or char arrays.
in C#
---------------
I rewrote HangerIn2
public struct HangerIn2
{
public HangerIn hangerIn; //I just added the HangerIn struct as a member
// New USP2 properties
public double kingWidth;
public double kingHeight;
public double []bearingLength;
public bool concealedFlange;
};
I did the same for HangerOut2 which contains several arrays.
The converted code in C#
public interface IHangerAssignment
{
void Analyze(HangerIn2 hgrIn, ref HangerOut2[] hgrOut, int maxOutput, ref int nResults);
}
When this function is called, that is when I get the error "Specified array was not of the expected type."
I did notice that when stepping through the debugger that the members are always listed in alphabetical order.
|
|
|
|
|
LeonardLay wrote: in C#
---------------
I rewrote HangerIn2
public struct HangerIn2
{
public HangerIn hangerIn; //I just added the HangerIn struct as a member
// New USP2 properties
public double kingWidth;
public double kingHeight;
public double []bearingLength;
public bool concealedFlange;
};
Look, without knowing what both structs looked like in C++, I haven't a hope in heck of helping you that much, though I think that
void Analyze(HangerIn2 hgrIn, ref HangerOut2[] hgrOut, int maxOutput, ref int nResults);
should be
void Analyze(ref HangerIn2 hgrIn, HangerOut2[] hgrOut, int maxOutput, ref int nResults);
|
|
|
|
|
Hi,
I use the following wmi call on an 32 bit xp pro machine.
What is the equivalent but for a 64 bit windows server machine please?
ManagementScope myScope = new ManagementScope(myServerName + "\\root\\cimv2", options);
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN32_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
Thanks
|
|
|
|
|
ManagementScope myScope = new ManagementScope(myServerName + "\\root\\cimv2", options);
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN64_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
Isn't it obvious?
|
|
|
|
|
Hi,
I still get access is denied.
Please note that using this code under a 32 bit machines runs fine.
I have also made sure that I do have admin rights on the 64 bit machine.
Any thoughts please?
|
|
|
|
|
Didn't you notice joke icon? It was a joke!
I think the same code should run on 64bit as on 32bit. If you are getting an error you should post it. It can be a permission issue. You can use WMICodeCreator[^] to quickly create WMI code.
Hope it helps.
|
|
|
|
|
Hi,
It seems that every 32 bit machines works fine under this code but not any of the 64 bit machines.
Question:
How can this code under 64 bit machine when the select query is looking at win32 ?
The error I get on a 64 bit remote machine is :
Connection error (username or password might be incorrect: Access is denied.)
Note that this is the admin user login that I am using and all the machines seem fine except the 64 bit rmote machines.
Any thoughts please?
Thanks
|
|
|
|
|
There is no "64-bit version".
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
arkiboys wrote: How can this code under 64 bit machine when the select query is looking at win32 ?
The WIN32 reference has NOTHING to do with how many bits your OS uses for integers. It is related to the Win32 interface for Windows, so the code wouldn't change. What you need is permission to access Win32 resources, which may be forbidden by default on 64-bit versions of WinOS.
|
|
|
|
|
I see.
Do you know where to look into this please?
|
|
|
|
|
|
Many thanks for the links,
I had spotted the microsoft link but not the one in code project...
I read all of them but there is nothing that related to why I get access denied error.
I even checked the settings as it mentions in the code project link and even compared it to the machine which does not give access denied but I still have the same issue of access denied.
Any thoughts please?
Thanks
|
|
|
|
|
OK, in your original code, you use a variable named options as an argument. What type is it?
|
|
|
|
|
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
|
|
|
|