|
Hi,
Im assuming an ArrayList is similar to Java's Vector class, however im having trouble accessing individual elements in the ArrayList and I cant see any methods there to get elements.
someone ?
|
|
|
|
|
You access it just like an array
ArrayList al = new ArrayList();
MyDataType elementZero = (MyDataType) al[0];
MyDataType elementOne = (MyDataType) al[1];
James
Sonork ID: 100.11138 - Hasaki
"Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. " - Michael P Butler Jan. 18, 2002
|
|
|
|
|
Hi,
I have managed to get my program to load types successfully, but when it comes to try and invoke a method that they support i get a compile error.
Exception of type System.InvalidCastException was thrown.
The type array has been filled using this short code.
if(null != type.GetInterface(typeof(IPlugable).FullName)) {
Console.WriteLine("Loaded");
loadedTypes[idx++] = type;
}
This is the code which doesnt work. Anyone have a dime of an idea ?
public void LoadTypes(Type[] types) {
IPlugable yer = (IPlugable)Activator.CreateInstance(plugins[x]);
yer.AFuntion();
}
|
|
|
|
|
odd, from what i see there that code should work fine. Make sure that you don't have two different IPlugable's defined. If you do its probably a namespace issue thats causing the problem.
I assume that plugins[x] is the array thats filled in the first block of code?
Perhaps if you posted more code something will pop out.
James
Sonork ID: 100.11138 - Hasaki
"Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. " - Michael P Butler Jan. 18, 2002
|
|
|
|
|
I’m using List-view controls with the LVS_OWNERDATA style and I’m trying to handle notification messages LVN_ODCACHEHINT and LVN_ODFINDITEM.
Any help on this would be great.
|
|
|
|
|
I was considering trying to write something simple to interface with my scanner. Could someone point me in the direction of some .NET info dealing with this?
I know of the Still Image API, but is there something in .NET for it?
|
|
|
|
|
AFAIK there is no built in support for scanning. You might be able to interface with TWAIN through .NET interop, but its sure to be messy.
I heard that Lead tools was releasing an imaging product for .NET. That might have what you need.
--
Peter Stephens
|
|
|
|
|
I need to read a .ini file under windows directory.
But the name of the directory may be different on different machines.
In some machine it is winnt while on ohters it is windows.
So, how to get the name of the directory.
I used GetPrivateProfileString with VC++. and I tried the whole
afternoon to get it worked under C# but it just cannot return the string.
the declaration of GetPrivateProfileString in VC++ is:
DWORD GetPrivateProfileString(
LPCTSTR lpAppName, // section name
LPCTSTR lpKeyName, // key name
LPCTSTR lpDefault, // default string
LPTSTR lpReturnedString, // destination buffer
DWORD nSize, // size of destination buffer
LPCTSTR lpFileName // initialization file name
);
And I converted it to
static extern int GetPrivateProfileString(
string appName, string keyName, sttring default, ref string strReturn,
int size, string fileName);
But I got System.NullReferenceException.
How to solve these two problems or any one of them?
|
|
|
|
|
I don't know a lot about C#, but I do know there is a Windows API to get this directory:
UINT GetWindowsDirectory(LPTSTR lpBuffer, UINT uSize);
Look it up in MSDN for details.
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
If I declare it as
static extern int GetWindowsDirectory(ref string strDir, int size);
and call it as
string strDir = "";
GetWindowsDirectory(ref strDir, 20);
I still got the NullReferenceException.
The point is how to get the value back from the function.
|
|
|
|
|
You need to use the StringBuilder class instead of string.
StringBuilder strDir = new StringBuilder(20);
GetWindowsDirectory(ref strDir, 20);
James
Sonork ID: 100.11138 - Hasaki
"Not be to confused with 'The VD Project'. Which would be a very bad pr0n flick. " - Michael P Butler Jan. 18, 2002
|
|
|
|
|
Hai,
I wrote a windows service application using c#. I am able to install it using InstallUtil.exe provided by .NET framework. But I want to install the same service on a different machine which does not have .NET framework.
I think, InstallUtil.exe comes only when you install .NET (correct me if I am wrong). But I dont want to install .NET framework just for this utility.
Does c# provide any class which can be used to install a service? I read about ServiceProcess.ServiceController. But this only helps me to monitor the installed services.
Any suggestions...
omkamal
|
|
|
|
|
Oops Sorry folks.
I read that you need .net framework to atleast run a .NET application ( no matter its a service or whatever ). So there is no way but to rely on InstallUtil.exe.
Thanks anyways
omkamal
|
|
|
|
|
Hai,
Can anyone tell me how to get the name of the computer (in which the code is running) using c#?
thanks.
|
|
|
|
|
Thought this one should do
String s = System.Diagnostics.Process.GetCurrentProcess().MachineName;
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Its giving me only a '.', its not giving me the name of the machine. any other suggestions????
omkamal
|
|
|
|
|
Ok. This is what I found out. I dont think there is a direct GetComputerName function in c# (as far as I know). Instead I read the following registry key
HKLM\System\CurrentControlSet\Control\ComputerName\ComputerName.
I hope this key is created in all machine because the System subkey stores sys related info.
If anyone wants to know the computer name, this is next to a good solution. Use, Microsoft.Win32 namespace for Registry related classes in c#.
One more thing "Naivete" and "omkamal" are one and the same. I just changed my username.
Thanks for your help.
omkamal
|
|
|
|
|
You're right, it doesn't work on my system either. According to .NET documentation, MachineName property should return the name of the system
Gets the name of the computer the associated process is running on.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
But if you read the document further it will also say that this property holds true only when you are trying to reach a remote computer...
Remarks
Specify a value for the MachineName property to view the processes running on another computer on the network. You can view statistical data and process information for processes running on remote computers but you ....
omkamal
|
|
|
|
|
omkamal wrote:
But if you read the document further it will also say that this property holds true only when you are trying to reach a remote computer...
Sorry, I was obviously mistaken.
I guess you can try SystemInformation::ComputerName, as suggested in another post.
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
Naivete wrote:
Can anyone tell me how to get the name of the computer (in which the code is running) using c#?
Try this:
string s = SystemInformation.ComputerName;
Kelly Herald
Software Developer
Micronpc, LLC
|
|
|
|
|
Awesome! Thanks Kelly. I appreciate your reply. I was so surprised how come c# doesnot provide such a functionality. But shame on me, that I felt so frustrating to check every single class for it. Nor did I try different search strings.
Thanks again,
Omkumar.
omkamal
|
|
|
|
|
|
Sorry if I underestimated c#. Here you go. One more property to get the machine name...
System.Environment.Machinename
omkamal
|
|
|
|
|
Will VS.NET require Product Activation like Windows XP ?
|
|
|
|