|
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 ?
|
|
|
|
|
I did not install it yet, but it does not look like it will need activation, because a key is provided to MSDN subscribers.
|
|
|
|
|
Hi,
I have an array of type Type[] foo;
how can i get the number of emelemts and size of this array if im passing it into an function ?
I tried foo.Count but that doesnt seem to be valid.
Any ideas ?
|
|
|
|
|
Hi ,
Try foo.Length
Cheers,
Joao Vaz
|
|
|
|
|
The first release of Magic is now available. This release includes docking windows with the look and feel of the VS.NET ones. It can host Control or Form derived objects and have context menus and floating/docked states. Go to the following website...
www.crownwood.net
The source, samples and tutorials can be downloaded and used free of charge for both personal and commercial purposes.
Phil Wright
phil.wright@crownwood.net
|
|
|
|
|
How do I simulate downcasting in C#?
public class foo
{
}
public class bar : foo
{
}
foo f = new foo();
// The following line
// causes a run-time error.
// InvalidCastException
bar b = (bar)f;
************************
The following doesn't work either.
This gives a compile error.
public class foo
{
}
public class bar : foo
{
public bar(){}
public bar(foo f)
{ this = f; }
public static explicit operator bar(foo f)
{ return new bar(f); }
}
|
|
|
|
|
AFAIK that can't be done in C#. The 'foo' object never was a 'bar' object and can't be cast in that direction. A new 'bar' reference CAN be cast into a foo reference and then back into a 'bar' reference though.
You cannot cast this way in a strongly typed language. You may be able to do this in C++ (with reinterpret_cast) but the virtual tables will be messed up and strange bugs WILL happen.
--
Peter Stephens
|
|
|
|