|
I Am doing Memory Scanner, Like Cheat Engine. If I acsess Memory and hdd with method Asynth or Synth what woud be better? Does delete command free Memory without closing process?
|
|
|
|
|
What delete command? Where do you read the data from and what do you need to store in your large list?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
The question is, if you buy more RAM, how much will your users need ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
My Process was about 500MB in memory. I Have 2GB of ram. And not all of pshical ram used, let alone windows Virtual Memory
|
|
|
|
|
Well, that is odd. I've had an app in development use 1 gig before. And once you run out of physical memory, it should swap to the HDD.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
public struct ProcessInfo<br />
{<br />
public bool bTaskBar;<br />
public int iProcessID;<br />
public String sTaskBarText;<br />
public String sFileName;<br />
public int iThreads;<br />
<br />
}<br />
<br />
static void Main(string[] args)<br />
{<br />
List<ProcessInfo> lpi = new List<ProcessInfo>();<br />
<br />
do <br />
{<br />
ProcessInfo pi = new ProcessInfo();<br />
lpi.Add(pi);<br />
} while (true);<br />
}
|
|
|
|
|
First, learn how to post code snippets here.
Second, this code:
static void Main(string[] args)
{
List<processinfo> lpi = new List<processinfo>();
do
{
ProcessInfo pi = new ProcessInfo();
lpi.Add(pi);
} while (true);
}</processinfo></processinfo>
Should look more like this:
static void Main(string[] args)
{
List<processinfo> listOfProcesses = new List<processinfo>();
while (true()
{
ProcessInfo processInfo = new ProcessInfo();
if (processInfo != null)
{
listOfProcesses.Add(processInfo);
}
else
{
break;
}
}
}</processinfo></processinfo>
1) You had an endless loop.
2) Your variable names suck.
"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
|
|
|
|
|
1. I know i had endless loop. I wanted to fill my memory and using Virtual Memory as a test. But didnt happend. It threw me System.OutOfMemoryException. And even your sample has infinitive loop. processInfo will never be null, because you intalize it.
2. Read rule #8
|
|
|
|
|
You can also get that exception if you have Int32.Max (2,147,483,648) number of items in the list and then try to add another one.
|
|
|
|
|
Thanks for the info. So it was List limitation, not memory. I Hope i wont have to utilize hdd for temp storage.
|
|
|
|
|
You need to allow programs to access more than 2GB of memory on an OS level. Please read your OS manual to set that.
|
|
|
|
|
When new can't allocate the memory, it returns null .
"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
|
|
|
|
|
Hey
All I am trying to do is print a file from c# can't seem to get anything to work. Some of the requirements are:
1) need to have the print dialog box appear
2) print proper file
Thanks,
ZachBob
~Any help is good help
|
|
|
|
|
What sort of file, just text ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Hi,
have a look at the Process and ProcessStartInfo classes, and use Verb="Print"; that way
your default PDF reader will do the actual printing. AFAIK that is the easiest way.
There is one disadvantage: the PDF reader will remain open (unless you add more code to close it,
which is a bit tricky).
|
|
|
|
|
Thanks Luc,
Tried using the Process and ProcessStartInfo classes, but I am getting an Acrobat.exe - Application Error.
Here is my code:
Process printPDF = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.Verb = "Print";
psi.FileName = Server.MapPath(tmpPdf);
psi.CreateNoWindow = true;
printPDF.StartInfo = psi;
printPDF.Start();
What am I doing wrong?
|
|
|
|
|
Hi,
if this is a Windows app, just do psi.FileName=tmpPdf;
I don't know what Server.MapPath is.
is this an ASP.NET application? if so, where is the PDF file, is it on the server?
anyway, double-clicking the PDF file should open your PDF reader, try that and check it
prints OK from there. If not, your file is bad.
|
|
|
|
|
It is actually a web application.
Server.Map - Returns the physical file path that corresponds to the specified virtual path on the Web server.
The pdf opens just fine outside of the web app.
here is some more code to help out:
I start by combining some PDFs into one pdf, then I show it in a pane, then I want the print dialog box to show right after it loads in the pane...
tmpPdf = "/temp/" + Session.SessionID + ".pdf";
PrepareCombinedFile();
FileStream fs = new FileStream(Server.MapPath(tmpPdf), FileMode.Open);
byte[] pdf = new byte[fs.Length];
fs.Read(pdf, 0, Convert.ToInt32(fs.Length));
Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Length",pdf.Length.ToString());
Response.BinaryWrite( pdf );
Response.Flush();
Response.Close();
fs.Close();
try
{
Process printPDF = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.Verb = "Print";
psi.FileName = Server.MapPath(tmpPdf);
psi.CreateNoWindow = true;
printPDF.StartInfo = psi;
printPDF.Start();
}
catch(Exception ex)
{
throw new Exception(ex.Message, ex.InnerException);
}
|
|
|
|
|
Hi,
this code is running on the server, it attempts to print on the server.
I doubt that is what you want.
Your browser should allow you to print a loaded page (or PDF document) on the client side,
either an interactive browser (IE7, FF, ...) or a programmable one (WebBrowser) or a
program using WebRequest and GetResponse.
|
|
|
|
|
correct - I want the print dialog box to appear on the client side. And yes, I am able to print from the loaded page, but the client would like the print dialog box to appear immediately after the pdf loads. Why, I don't know .
|
|
|
|
|
Hi,
I don't know how to do that in a standard browser.
In a WebBrowser Control, I would use the DocumentCompleted event, then write standard
printing code.
|
|
|
|
|
Hi,
I now have seen some pages that do just that. It is based on the onload event and some
JavaScript, using window.print()
As an example, take this[^], click the little printer icon at the bottom, see another page load and have a look
at its source code.
Hope this helps.
|
|
|
|
|
I'm developing a USB device that is communicating with a C# program through a serial port interface.
I identify my device using SetupDiGetDeviceRegistryProperty, reading the HardwareId and searching for my VID and PID in the string that is returned. (Don't know if this is the fastest/best way, but it works...)
For the communication I would like to use a SerialPort component so I need to get the COM port used by my device but I can't find that information using SetupDiGetDeviceRegistryProperty.
Using the Device manager the information is available under Properties/Port Settings/Advanced/Com port number and in the registry it can be found at HKLM\Hardware\DeviceMap\SerialComm but how do I access that information from my C# code?
Thanks!
|
|
|
|
|
Hello Forum
I was looking for a way to dynacmicly open a form and realize that the best way will be to use reflection.
It is the first time i am using reflection and think that i am alomost there but it still doesnt work.
i am getting a message "Object does not match target type."
Bellow is the code.
Please help
Type theType = Type.GetType("WindowsFormsApplication1.Form2");
MethodInfo[] method = (from met in theType.GetMethods()
where met.Name == "Show"
select met).ToArray();
Activator.CreateInstance(theType);
method[0].Invoke(theType, null);
|
|
|
|