|
Yes, I guess it's possible using SDK Memory related API's.
Can't recall the exact API's though (had used them some 5yrs back ), try finding them on MSDN.
Hummm .... can recall of one called "GetSystemInfo" which returns info about current system.
Good luck !!
Regards,
Bhupi Bhai.
|
|
|
|
|
Thanks very much in advance!
I'll give it a try (GetSystemInfo in kernel32.dll)!
Martin
|
|
|
|
|
Hello,
Had no luck with that.
GetSystemInfo returns a:
[StructLayout(LayoutKind.Sequential)]
class SYSTEM_INFO
{
public ushort wProcessorArchitecture;
public ushort wReserved;
public uint dwPageSize;
public IntPtr lpMinimumApplicationAddress;
public IntPtr lpMaximumApplicationAddress;
public IntPtr dwActiveProcessorMask;
public uint dwNumberOfProcessors;
public uint dwProcessorType;
public uint dwAllocationGranularity;
public ushort wProcessorLevel;
public ushort wProcessorRevision;
}
I implemented it like that:
[DllImport("kernel32.dll", CharSet = CharSet.Unicode,CallingConvention = CallingConvention.Winapi, EntryPoint = "GetSystemInfo")]
private static extern void GetSystemInfo([In,MarshalAs(UnmanagedType.LPStruct)]SYSTEM_INFO pSysInfo);
And called it like that:
SYSTEM_INFO sysinfo = new SYSTEM_INFO();
GetSystemInfo(sysinfo);
But I didn't found a member that fits me needs
If I made something wrong, please let me know.
But again thanks for youre time.
Martin
|
|
|
|
|
Yes, ur on the right track.
But I am sorry can't recall the exact API for it.
You will have to do some more rnd on this.
Regards,
Bhupi Bhai.
|
|
|
|
|
Found it!
GlobalMemoryStatus from kernel32.dll
Thanks again!
|
|
|
|
|
I would suspect you can get the info though WMI. Using WMI from C# is fairly simple - you should be able to get a sample from Google. I would probably try to split the search into two:
1) How to use WMI from C#
2) How to get the free memory though WMI (in any language)
just in case you can't easily find an example getting the free memory from C#.
|
|
|
|
|
Hello,
I think I found it 5minutes ago.
But I will need it in future.
Thank you.
All the best,
Martin
|
|
|
|
|
Yes, lmoelleb (is that ur name) is right.
Using WMI in C# you can get Free Physical Memory.
ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection queryCollection1 = query.Get();
foreach(ManagementObject mo in queryCollection1 )
{
Console.WriteLine("Free Physical Memory : " + mo["freephysicalmemory"].ToString());
}
Regards,
Bhupi Bhai.
|
|
|
|
|
Got it now!:->
Here is what I'm using now:
[StructLayout(LayoutKind.Sequential)]
class MEMORYSTATUS
{
public IntPtr dwLength;
public IntPtr dwMemoryLoad;
public IntPtr dwTotalPhys;
public IntPtr dwAvailPhys;
public IntPtr dwTotalPageFile;
public IntPtr dwAvailPageFile;
public IntPtr dwTotalVirtual;
public IntPtr dwAvailVirtual;
}
[DllImport("kernel32.dll", CharSet = CharSet.Unicode,CallingConvention = CallingConvention.Winapi, EntryPoint = "GlobalMemoryStatus")]
private static extern void GlobalMemoryStatus([In,MarshalAs(UnmanagedType.LPStruct)]MEMORYSTATUS lpBuffer);
Maybe somebody needs it.
Thanks for the replies.
All the best,
Martin
|
|
|
|
|
Hi all,
I am working on Windows Service Application.I want to call a webservice and to retrive Output xmlfile values generated by the webservice.
I have done the same in Windows Application.It worked.
but if i use the same code in Windows Service,i got this System.Net.WebException.
//to call the Webservice
localhost.Service service = new SDSettingsServices.localhost.Service();<br />
<br />
service.GetSNCompleted += new SDSettingsServices.localhost.GetSNCompletedEventHandler(service_SN);<br />
<br />
service.GetSNAsync(Corpname, divisionname);
public void service_SN(object o, SDSettingsServices.localhost.GetSNCompletedEventArgs e)<br />
{<br />
string serial = e.Result.SerialNo;<br />
}<br />
<br />
PLz help me to find out the exception.
Is there any other method to call a webservice from Windows Service..
Thanks in Advance,
cheers
sangeet
|
|
|
|
|
What was the error message in the WebException?
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for ur Reply..
i got this error.
WebException was unhandled/
The request failed with HTTP status 403: Forbidden.
cheers
sangeet
|
|
|
|
|
Please check the account under which the service is running. By default windows applications runs under the currently logged on user's credentilas who is mostly having all access. But when you run windows service there are different account under which you can run the service.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
Thanks for ur suggestions..it worked..
cheers
sangeet
|
|
|
|
|
Hello,
I have some strings which I want to replace them with single quotes so that I can use them as arguments that are passed to a sql query.
Example, string variable Name:
"Peter John"
Should be replaced with single quotes
'Peter John'
so name should contain only 'Peter John'
Is there any possible way to do this.
Many thanks,
Steve
|
|
|
|
|
u can try string.Replace() method
rahul
|
|
|
|
|
Hello,
I have tried that already. The replace method has 2 overloaded methods. One that accepts unicode, and the other that accepts strings.
I did this:
name.replace(39,34) unicodes for " and '. didn't do anything.
name.replace(" " ", " ' ") accepts the single quote, but has syntax for the first argument.
Any ideas on the above,
Thanks very much,
Steve
|
|
|
|
|
if ur passing string value in sql query then in that sql query u can pass the value in following way "insert into xyz values('"+name+"')";
rahul
|
|
|
|
|
lets say we have a string variable that is called name and has in it the name that you want to use:
<br />
String name;<br />
name = name.Replace('\"', '\'');<br />
Note: \ is the escape character
|
|
|
|
|
Hello,
Thanks for the reply,
However, I used your method, but got an syntax error "Expression Expected"
Sorry for the confussion, but I should have posted this in the VB.Net forum. I thought i did.
I tried you code in C# and no syntax error, but still did not replace the double qoutes. When I put the mouse on name in debug mode after replace, it still have the double quotes.
code in c#,
<br />
string name = "Peter John";<br />
<br />
name.Replace('\"', '\'');<br />
<br />
MessageBox.Show(name);<br />
What am I doing wrong?
Thanks for your help,
Steve
|
|
|
|
|
Compare the code that you have with the code that quiteSmart posted. What have you removed?
Strings are immutable in .NET. That means that a value of a string can never be changed. To get a different string value you create a new string. That gives that the Replace method does not change the string that it's used on, instead it returns the new string.
---
b { font-weight: normal; }
|
|
|
|
|
string test = "\"Peter John\"";
Console.WriteLine(test);
string test1 = test.Replace('\"', '\'');
Console.WriteLine(test1);
Regards,
Bhupi Bhai.
|
|
|
|
|
Hai,
See the code below:
name="\"Peter John\"";
string SqlQuery = "Select * from employees where EmpName=" + name.Replace('\"', '\'') ;
This will give you the SqlQuery string value as "Select * from employees where EmpName='Peter John'"
Hope this will be useful..
Plz try this...
Regds
Abja
|
|
|
|
|
hi!
my need is to have multiple radio button selection.
i used a group box for each radio button.
but if i want to deselect a radio button i am not able to.
So please help me to have multiple selection and deselction of radio buttons
with regards,
Asha
hi!
|
|
|
|
|
hi,
y dnt u use CHECKBOX instead
hope this helps
Nitin...
|
|
|
|