Xcelled194 28 Junior Poster in Training

=> Three
what I meant is that if I wrote my code as a console application Can I easily change it to windows application by building the forms ??
and thanks a lot for your attention all

Yes you can. I wouldn't recommewnd it, as you'll need to tie your program logic into the form, which can be confusing if you've designed it around a console.

Xcelled194 28 Junior Poster in Training

Best solution would be to edit the App Manifest on Application TAb of the project properties. Set the requestedExececutionLevel to requireAdministrator

Xcelled194 28 Junior Poster in Training

I've downloaded files both ways quite a bit. I'd estimate somewhere around 500 for each. The file size is always 10 mb, and both FileZilla and my program report transferring the same number of bytes total, so it would seem the compression is the same for both.

Also, I do one right after the other, ie I use my program, then use FileZilla, so the network shouldn't change.

Xcelled194 28 Junior Poster in Training

Hi guys, I'm fairly new to C++, though I have several years of experience with C#.

I've made program with XAML and C++. Part of the program's job is to download several hundred 10mb files from an FTP patch server. I've been using the .NET FtpWebRequest for this task, and it works OK. However.....

I tested downloading the files with FileZilla, which is C++, and I got almost double the speed as my .NET program did. This is no insignificant difference, either. (3 mpbs vs 1.5mbps).

I've concluded that unmanaged C++ is significantly faster than C# (well, I knew that already...) and that I should place the FTP code in a separate C++ executable.... but I'm *really* lost as to how to do this.

I do know what the program needs to do:

  1. Receive 3 arguments, Host, Remote Path, and Local Path.
  2. Connect to FTP server anonymously
  3. Download said file, writing progress to STD out.
  4. Exit when the transfer completes.

I've looked at several C++ FTP libraries, but I can't seem to get a handle on anything. Can one of you help?

One last thing: I'd start the C++ exe from C#, supplying the arguments, then read the STD out to display progress on the UI.

Xcelled194 28 Junior Poster in Training

What I was looking for is to basically spawn another process, then exit immediately. I don't care about the output (there is none), I just want the PHP file to run. I solved it like this:

$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$lm = substr($url, 0, strlen($url)-strlen(strrchr($url, '/'))+1);
curl_post_async($lm . 'query.php');
die();

function curl_post_async($url)
{
   $post_string = '';

   $parts=parse_url($url);

   $fp = fsockopen($parts['host'],
       isset($parts['port'])?$parts['port']:80,
       $errno, $errstr, 30);

   $out = "POST ".$parts['path']." HTTP/1.1\r\n";
   $out.= "Host: ".$parts['host']."\r\n";
   $out.= "Content-Type: application/x-www-form-urlencoded\r\n";
   $out.= "Content-Length: ".strlen($post_string)."\r\n";
   $out.= "Connection: Close\r\n\r\n";
   if (isset($post_string)) $out.= $post_string;

   fwrite($fp, $out);
   fclose($fp);
}
Xcelled194 28 Junior Poster in Training

This is probably a very simple answer that I'm missing.

I have index.php and qeury.php in the same directory. Users visit index.php, which prints some info. It then needs to call qeury.php and exit, without waiting for query to finish running. Query just pings a server and then exits.

How does one accomplish this?

Xcelled194 28 Junior Poster in Training

I need some help creating a regex. It seems like a simple problem, but I cannot, for the life of me, wrangle out the regex.

All the regex should do is match an 'e' that is not preceed by a '\', unless there is a space between them.

Example: In this string

\viewkind4\uc1 Suspect Document

the regex would match the e in Suspect and Document, but not \viewkind


Can anyone help me out?

Xcelled194 28 Junior Poster in Training

Yeah, SQL is not the way to go. I've found WMI or PsExec usually does it.

Xcelled194 28 Junior Poster in Training

Hi guys, I'm writing a program that needs to log on to a remote computer to preform a task. I have the user name and account, but I need a way to logon as that user on the remote machine.

Edit: All I need to do is copy a file between machines, and *perhaps* invoke it or modify the registry. Not sure on that part yet.

Xcelled194 28 Junior Poster in Training

I did, but see my bug report link in the last post. Turns out its a bug with the server, so I thehave to contact dotster.... I downloaded XAMPP and tested my code with that (I copied my php.ini from my webserver to xampp so the config was the same) and it worked every which way I tried it. Http://example.com, http://example.com/page.html, ect, all worked.

Also, for some reason, ab said the fopen_wrappers only applied to fopen(). This is not the case. Regardless, the problem is solved.

My way, works.
Almostbob messed up.
Fix it.

:D

Xcelled194 28 Junior Poster in Training

its not on your site

your way, does not work
the right way, works

no further discussion required

ya messed up
fix it

[flush]

Oh that is very helpful.

NO, the right way does NOT work. If you TRIED to solve my problem, you would have come up with this: http://www.codingforums.com/archive/index.php/t-140180.html

Seriously, you were extremely unhelpful after your first post, even condescending. That is NOT the attitude this site endorses.

And, when I prove you wrong, you reply with

"its not on your site

your way, does not work
the right way, works"

Which is just like a lot of answers I receive from some 3rd world tech support hotlines, AKA worthless, uninformed, confusing, unintelligible, and almost entirely unhelpful.

Plus, all the
"ya messed up
fix it"
doesn't do a whole lot for me. No, YOU, my friend, messed up. YOU fix it.

Xcelled194 28 Junior Poster in Training

Read more carefully. Wrappers! not the fopen() itself! If you looked, the link points to http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen which is an INI file setting. It has NOTHING to do with fopen().

My INI has those turned on. So I CAN use URLs

I'll even quote you the example in the PHP manual.

Example #1

<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>

Look familiar?

Xcelled194 28 Junior Poster in Training

you are reading a file
the documentation requests a file
the function file_get_contents() should suggest a file
the op states
http://www.example.com is not a file, and not even the uri from the original post
a file is http://www.example.com/FILENAME.FILE_EXTENSION

PHP, according to the manual, should correctly resolve and retrieve http://www.example.com with file_get_content(). In an attempt to solve my problem, I tried to follow the example to the letter.

Also, from the op, http://example.com/page.html IS a file URI. Regardless, 99.99% of webservers, including example.com, automatically serve up the index if no file is specified. The other .01% return SOME kind of file.

All this happens internally in the server- meaning PHP can't tell the difference. As far as it's concerned, it requests a file, and one is returned.

So http://www.example.com/ does indeed point to a file.

Xcelled194 28 Junior Poster in Training

Nono, that is eactly what I have in my code: "http://www.example.com"

Here is the complete script:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('user_agent',$_SERVER['HTTP_USER_AGENT']); //Didn't fix problem
echo file_get_contents('http://www.example.com/'); ?>
Xcelled194 28 Junior Poster in Training

now I get this:

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/test.php on line 4

Warning: file_get_contents(http://www.example.com/): failed to open stream: No such file or directory in /www/test.php on line 4
Xcelled194 28 Junior Poster in Training

I need to retrieve a HTML file from an external site (http://example.com/page.html) and parse it. Parsing it is fine, however I can't seem to find a way to retrieve the file given this:

  • Cannot use cURL
  • Must work on PHP 4.3.9+
  • Must retrieve the file as a HTTP request
  • Must return file as a string

Can anyone suggest something that meets these requirements?

Edit: Running

echo implode('', file('http://www.example.com/'));

returns this:

Warning: file(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /www/test.php on line 4

Warning: file(http://www.example.com/): failed to open stream: No such file or directory in /www/test.php on line 4

Warning: implode(): Bad arguments. in /www/test.php on line 4
Xcelled194 28 Junior Poster in Training

You can use proc_open() to open multiple php processes. You can open a process to a PHP file that will run the server online test. You don't have to wait for proc_open() to return, so you can run it multiple times.

If you want to read the returns async, then use stream_select(). Otherwise you can just have the php scripts called by proc_open() write to persistent storage, like a db or file with the results.

You can also use exec() to execute processes async. eg:

exec('php /path/to/server_online_test.php http://example.com &');

That would call /path/to/server_online_test.php passing it "http://example.com" as an argument. You can retrieve the argument via $argv[1]

Thanks, exactly what I was looking for!

Xcelled194 28 Junior Poster in Training

And (pardon my noobishness) that code is asyc? That is, it will immediatly move on to the next server?

Xcelled194 28 Junior Poster in Training

Yeah, not quite what I want. the detection code is fine, it just loads really slow when servers are offline.

Xcelled194 28 Junior Poster in Training

Hi guys,

Recently moved into PHP for a personal application. Basically, it tries to connect some servers to see if they're online. It ultimately returns a string, which the caller echos. The main function is:

function IsServerOnline($IP, $checkforevent = TRUE, $ischannel = TRUE, $PORT = 11020)
 {
	global $UseGlobalOverride, $UseChannelOverride, $GlobalOverride, $ChannelOverride, $UseOfflineOverride, $OfflineOverride, $IsEvent;
	if ($UseGlobalOverride) return $GlobalOverride;
	if ($UseChannelOverride && $ischannel) return $ChannelOverride;
	
	$fp = fsockopen($IP, $PORT, &$errnum, &$errstr , 2);
	if (!$fp)
	{
		if ($UseOfflineOverride) return $OfflineOverride; else return "offline";
	} 
	else
	{
		fclose($fp);
		if ($checkforevent && $IsEvent) return "event"; else return "online";
	}
 }

and it is called by this:

|Server1=<?php echo(IsServerOnline("208.85.108.17", TRUE, TRUE, 80)); ?><br>
|Server2=<?php echo(IsServerOnline("63.251.217.212", FALSE, FALSE, 80)); ?><br>
|Server3=<?php echo(IsServerOnline("208.85.108.15", FALSE, FALSE, 11000)); ?><br>

It all works wonderfully, except when a server goes down. Then, the "timeouts" kick in, and the page gets slow to load. I have approximately 50 servers to test, so this webpage gets very slow at times. What would be my best bet for running the tests asynchronously and then printing the correct output in the correct place?

Xcelled194 28 Junior Poster in Training

I'd say it depends on how much "design" you're doing. Panels are good for single complex graphics (think background picture) and are generally easier to configure/maintain than labels and pictureboxes.

HOWEVER panels DO incur a performance overhead, and they have the annoyance of grabbing controls for children, whether you want that or not. If you're worried about overhead and/or you have a lot of overlapping controls, go with the Label/Picturebox.

If you're basically painting your UI though, it's time to look at a custom control specifically tailored to your needs, as this will be (significantly) less overhead and you can tweak its features precisely.

Xcelled194 28 Junior Poster in Training

Could you use Panels? If not, try creating your own custom control. You can set its shape with the Region property.

Xcelled194 28 Junior Poster in Training

I suggest you make your own thread for that instead of hijacking this one.

Xcelled194 28 Junior Poster in Training

OK, well, this is actually very simple. Here is my example, it is a console appication and it uses a const string of the song paired with a StringReader. However, it should be very easy to adapt it to use a StreamReader.

class Program
    {
        const string Song = @":beep frequency=660 length=100ms;
:delay 150ms;
:beep frequency=660 length=100ms;
:delay 300ms;
:beep frequency=660 length=100ms;
:delay 300ms;
:beep frequency=510 length=100ms;
:delay 100ms;
:beep frequency=660 length=100ms;
:delay 300ms;
:beep frequency=770 length=100ms;
:delay 550ms;
:beep frequency=380 length=100ms;
:delay 575ms;
:beep frequency=510 length=100ms;
:delay 450ms;
:beep frequency=380 length=100ms;
:delay 400ms;
:beep frequency=320 length=100ms;
:delay 500ms;
:beep frequency=440 length=100ms;
:delay 300ms;
:beep frequency=480 length=80ms;
:delay 330ms;
:beep frequency=450 length=100ms;
:delay 150ms;
:beep frequency=430 length=100ms;
:delay 300ms;
:beep frequency=380 length=100ms;
:delay 200ms;
:beep frequency=660 length=80ms;
:delay 200ms;
:beep frequency=760 length=50ms;
:delay 150ms;
:beep frequency=860 length=100ms;
:delay 300ms;
:beep frequency=700 length=80ms;
:delay 150ms;
:beep frequency=760 length=50ms;
:delay 350ms;
:beep frequency=660 length=80ms;
:delay 300ms;
:beep frequency=520 length=80ms;
:delay 150ms;
:beep frequency=580 length=80ms;
:delay 150ms;
:beep frequency=480 length=80ms;
:delay 500ms;
:beep frequency=510 length=100ms;
:delay 450ms;
:beep frequency=380 length=100ms;
:delay 400ms;
:beep frequency=320 length=100ms;
:delay 500ms;
:beep frequency=440 length=100ms;
:delay 300ms;
:beep frequency=480 length=80ms;
:delay 330ms;
:beep frequency=450 length=100ms;
:delay 150ms;
:beep frequency=430 length=100ms;
:delay 300ms;
:beep frequency=380 length=100ms;
:delay 200ms;
:beep frequency=660 length=80ms;
:delay 200ms;
:beep frequency=760 length=50ms;
:delay 150ms;
:beep frequency=860 length=100ms;
:delay 300ms;
:beep frequency=700 length=80ms;
:delay 150ms;
:beep frequency=760 length=50ms;
:delay 350ms;
:beep frequency=660 length=80ms;
:delay 300ms;
:beep frequency=520 length=80ms;
:delay 150ms;
:beep frequency=580 length=80ms;
:delay 150ms; …
Xcelled194 28 Junior Poster in Training

This sounds like a job for reflection. Unfortunately, my experience with reflection is limited, so I suggest googling "C# Reflection Method Name".

EDIT: quick google search, this looks exactly like what you want: http://en.csharp-online.net/CSharp_FAQ:_How_call_a_method_using_a_name_string

ddanbe commented: Excellent advice. +14
Xcelled194 28 Junior Poster in Training

Hi guys, I'm making an Etch A Sketch program in C#. I have two buttons for the "knobs". Right now, I'm handling the mousemove event of the button to evaluate if the user is dragging the mouse up or down, and then updating the etch a sketch appropriatly.

This works fine, as long as you drag the mouse vertically. However, in real life, you rotate the knobs clockwise or counter clockwise. Can someone help me to puzzle out the algorithm to determine if they're dragging clockwise or counterclockwise?

I'm thinking something with comparing the current mouse coordinates with a previous "snapshot", but the answer is just beyond my thoughts. Can anyone help?

Xcelled194 28 Junior Poster in Training

Hello guys, for a School assignment, I need to code a program in VB.NET or C#. The only requirements of this program are:

  • It must use file IO in some form
  • It must take between 1 and 4 weeks to finish (assuming that I work on it 1-2 hours a day)

I don't want to do something "simple" like a Connect 4 game. I'm hoping that those of you with real world experience can suggest some "neat" ideas on what I should code. Ideally, this would have a big "Wow!" factor.

Xcelled194 28 Junior Poster in Training

One of the things that always irked me about C# is its lack of an InputBox function. In VB, You can simply do

response = InputBox("Enter your name")

Unfortunately, there is no C# equivalent. Sure, you can call the VB one, but doesn't that kind of defeat the purpose of C#? So, like any good programmer, I set out to make my own pure C# InputBox. Its fairly bare bones, but it gives all the functionality of the VB InputBox.

You can use it by including the InputBox class in your program's namespace and calling it like this:

string lang = InputBox.Show("What's your favorite language?", "Language", "C#", -1, -1);

Notes:

  • Because C# 3.5 and below doesn't support optional parameters, you must supply an argument for every parameter.
  • For the xPos and yPos, passing in -1 will center the form in the corresponding direction. (x is horizontal, y is vertical)
  • There is almost nothing in the way of error trapping, because I feel that you, the end programmer, can best trap the errors as suited to your project. Simply surrounding InputBox.Show() with a try statement should prove adequate.
  • If the user presses cancel, InputBox.Show() returns an empty string ("")
  • If you modify/distribute the source code, please retain my information comment, however you may add yourself as an author.
  • PM me with any features you think this should have or any bugs you find.
ddanbe commented: Good. +14
Xcelled194 28 Junior Poster in Training

Add a reference to Microsoft.VisualBasic and you can do:

string response = Microsoft.VisualBasic.Interaction.InputBox("Prompt", "Title", "DefaultResponse",5,5);

While this gets the job done, I'd recommend making a form like Mitja Bonca suggested, as it's pure C# and infinitely more customizable.

Xcelled194 28 Junior Poster in Training

OK, I'm making a program that pulls information out of a DaniWeb Profile page using a WebBrowser. However, it's frankly getting annoying having to click "Member log-in" each time, and this is something you'd do multiple times a day, possibly with different accounts. So, I thought, why not have it pop up the box automatically? Some digging into the HTML revealed this:

<a
 href="/forums/register.php" id="loginlink">Member
Log In</a>

<!--Annnd a little while later... -->

<script type="text/javascript"> <!--

$(function() {

$('a#loginlink').bind('click', function() {
$("#loginform").dialog( { modal: true });
return false;
});
//--> </script>

To my semi-trained eye, that looks like its intercepting the click event of the Login Link to show the custom dialog box. Great, I thought. I just need to simulate a click on that link.

Of course, the simple things never are. Here is the base code that triggers the box:

private void Form1_Load(System.Object sender, System.EventArgs e)
	{
            wbMain.ScriptErrorsSuppressed = true;
            //// skip error messages.
            ShowLoginBox();
	}
    private void ShowLoginBox()
    {
        
        wbMain.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wbMain_DocumentCompleted); //When the page loads, open login box.
        wbMain.Navigate(urlDaniWeb);
    }

    void wbMain_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        try
        {
            //OK, this is where everything is failing (I separated different attempts):

            //HtmlElement el = wbMain.Document.All["loginlink"];
            //el.InvokeMember("Click");
            //======================================================================
            //HtmlElement el = wbMain.Document.All["loginlink"];
            //el.InvokeMember("Click");
            //object obj = el.DomElement;
            //System.Reflection.MethodInfo mi = obj.GetType().GetMethod("click");
            //mi.Invoke(obj, new object[0]);
            //======================================================================
            //HtmlElement btn = wbMain.Document.GetElementById("loginlink");
            //btn.InvokeMember("click"); 
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        wbMain.DocumentCompleted -= wbMain_DocumentCompleted; //Unsubscribe, we don't want this going off like nuts
    }

Summary of the errors:

Xcelled194 28 Junior Poster in Training

I have a program that must copy a file to 3 locations, the local hard disk, a USB drive, and a network location. I have the file (about 70mb) loaded into a byte array. My quesion is, since I'm not actively modifying the byte array, can I impliment a form of multithreading where all 3 threads read the same byte array at the same time?

Xcelled194 28 Junior Poster in Training

Hi guys, I want to add an animated taskbar icon to my WPF project. I figured I would just use the Icon property, but I'm fairly new to WPF, and I dont know how to do it. In Winforms I would create a thread like this:

Private Sub AniIcon()
Do
'I split a gif into its individual frames and then load them sequentially
Me.Icon = Image.FromFile("Path\to\split\GIF\here") 
System.Threading.Thread.Sleep(250)
Loop
End Sub

But I can't find a Window.Dispatcher to use this approach in WPF. I also see something about "BeginAnimation" in the Icon Property?

So, what is the best way to do this?

Xcelled194 28 Junior Poster in Training

Ok, thanks to your lead (and my C# book) I think I figured it out. I needed:

Customer myC = BindingOperations.GetBinding(ProgramBox, ComboBox.SelectedValueProperty).Source as Customer;
Xcelled194 28 Junior Poster in Training

I think I understand, its just, this is my first "real" WPF app, and I am totally confused by it. lol.

Xcelled194 28 Junior Poster in Training

OK, you can stop with the insults. Your posts have no relevance to the OPs question. It has been answered. If you have an issue with me, take it to the PMs.

I request this thread be marked as solved. The OPs question has been given two relevant answers.

Xcelled194 28 Junior Poster in Training

with

m_updateData.Barcode = this.barcode;
m_updateData.ShowDialog() // POP up the new form

this.Close(); // Close the new form

if you want to close the new form, you'd need to do this:

m_updateData.Barcode = this.barcode;
m_updateData.ShowDialog() // POP up the new form

m_updateData.Dispose(); // Close the new form
Xcelled194 28 Junior Poster in Training

So why did you start one?

I didn't. I defended my response to the OP. So here we go, now I'm defending THAT response.

You cannot compare .NET with regex.

Oh really? So I can't time a replace program, one that uses String.Replace() and another using Regex.Replace()?

Also have a look at sed, awk and grep.

I don't see the relevance. They use regex.

Also have a look at the regex variants for Perl, Ruby, PHP, Python, C, Java.

Yeah, I'm familiar with them. Your point?

I've used Regex a lot, you shouldn't make assumptions. What I'm referring to is what happens when the user inputs a regex 'reserved' character? In this case '[' wasn't the best choice as it won't do anything, but '\' will.

I'm not sure what you mean by it 'being faster than .NETs stuff'. Regex is part of .NET.

But that isn't important. Yours will work if he validates input. Mine works (albeit slower) without validating input. 1/2 a dozen of one, 6 of the other.

Sorry, didn't mean to come across as assuming. I see what you mean now, I though you were referring to the word itself. Of course he should sanitize the input if he's going to release the program. Even replacing "\" with "\\" when its read will do.

As for ''being faster than .NETs stuff'', I've read lots of posts around the Internet about how regex offers a huge advantage over built in String methods.

Xcelled194 28 Junior Poster in Training

Momerath, you haven't used regex much at all have you? Its a faster and more reliable method than .NETs stuff. the "[" in regex is the start of a character class (group of characters). The "^" means "Not". If you needed to match literals of those, you'd escape them, just like in C#. "\[" matches "[".

regex actually supports more characters that NET does. You can implement ASCII and unicode char codes directly in the regex.

See http://www.regular-expressions.info/reference.html

But this isn't the place for a debate over NET vs Regex.

Xcelled194 28 Junior Poster in Training

I don't agree with

Also, for almost every item in .NET, .Close() and .Dispose() do the same thing. Call .Dispose() just to be safe, but understand that calling this.Dispose() will cause your application to fail.

They are NOT the same. Dispose() automatically calls close, but that is as far as the similarities go. Close() is the same as Visible = False. It just hides the form, but the form takes up memory.

Dispose() releases the form. Basically, it frees all memory used by the form. This is NOT closing it. Think of it in terms of a newspaper. Close() just hides it from you. Dispose() actually removes it.

That being said, be careful to only call dispose when you won't be using the form again.

Xcelled194 28 Junior Poster in Training

Better method is to use a regex. By using a negation on guessed letters, you get the same effect.

Something like:

//NOTE: In a real application, this would go in the code when the guess a letter, AFTER they enter a letter
            string word = "moo"; //For Test
            string guessedletters = "rmwe"; //For test

            string underscoredWord = System.Text.RegularExpressions.Regex.Replace(word, "[^" + guessedletters + "]", "_");

            Console.WriteLine(underscoredWord); //Replace with label
Xcelled194 28 Junior Poster in Training

Look into a Graphics API like OpenGL or DirectX for your graphics.

But if you just want a line between two points, look into the Graphics.DrawLine() function.

Xcelled194 28 Junior Poster in Training

Also, anywhere your function may exit, you need a return.

For example, consider:

bool GetError(bool error) {
if (error == true) {
    return true;
}
}

That snippet will throw the same error. What you need is

bool GetError(bool error) {
if (error == true) {
    return true;
}
return false;
}

Now in that example, it was pretty obvious. Just be careful if/when your methods start to get really intricate and convoluted.

Xcelled194 28 Junior Poster in Training

Try surrounding your Foreach loop with a

Lock (dictionary) {

}
Xcelled194 28 Junior Poster in Training

You say you call

This.close()

Are you also calling any relevant

This.Dispose()

?

Xcelled194 28 Junior Poster in Training

Hi all, I must admit I'm rather stumped by this one. I have a program that handles tickets/prizes for a business. Patrons obtain tickets, and then go to turn them in at a counter. An employee counts their tickets, and inputs that number into my program. The program then displays a list of prizes, filtered by ticket value. For example, under the Ticket Level 2 might be a pen and a coaster. Ticket level 5 might contain a t-shirt. Anyway, the users select how many of certain prize they want. The program then subtracts the appropriate number of tickets from the total.

I have this program working as a WinForm, by using variables (i.e. TicketsLeft) and a two column DataGridView, filtered by a ComboBox.

Here is an example of the existing WinForms program:
http://www.daniweb.com/forums/attachment.php?attachmentid=20127&stc=1&d=1300759795

Well, it worked great until the client decided to move to the flashy interface of WPF.

I'm rewriting the code, so it fills a "Customer" class with the information that used to go in the Form Variables, but I've hit a snag. I can't seem to access the underlying customer class to copy data back from the DataGridView.

Here is the working WinForms Code. (Pardon the Visual Basic):

If DataGridView1.Rows.Count <> 0 Then
            For I = 0 To DataGridView1.Rows.Count - 1
                For J = 0 To UBound(PrizeList)
                    If PrizeList(J, 0) = DataGridView1.Rows.Item(I).Cells(0).Value AndAlso PrizeList(J, 2) = ComboBox2.SelectedItem Then
                        If Not IsNumeric(DataGridView1.Rows.Item(I).Cells(1).Value) Then Me.GroupBox1.BackColor = Color.Red : GetLocalError(True) : …
Xcelled194 28 Junior Poster in Training
double dValue = 0.0;

at line 21.

Xcelled194 28 Junior Poster in Training

Hi, I'm writing a program that interfaces with built in Windows Tools like IPCONFIG.exe. For reasons of compatibility, this program runs an IPCONFIG.exe stored in the application directory. However, IPCONFIG.exe is dependent on several files in the System32 directory (it uses relative paths). Short of copying all of system32 into the application directory, I want to detect what files IPCONFIG.exe attempts to access - and then copy the relevant folder tree to the application directory. I can take care of the copying the tree, I just need a way to determine which files the program attempts to use.

Xcelled194 28 Junior Poster in Training

If I understand you right, you want

MyPictureBox = this.picturebox1;
Xcelled194 28 Junior Poster in Training

Hi guys, my program needs to manipulate the command line, and it needs administrator access. So, I'm using a Process with the administrator user name and password, then piping input back and forth. It works 100% if i leave out the credentials, but if I add them in, on the CMD window (NOT my app), it says "The handle is invalid" and then exits. Any idea what's wrong?

Command.exe is merely a copy of cmd.exe that's copied to the program directory for test purposes.

static System.Diagnostics.Process P;
		static string Prompt = ">>>";
		static System.IO.StreamReader Out;
		static System.IO.StreamWriter In;
        static System.IO.StreamReader Err;
        static bool GodModeOn = true;

        private static void StartProcess()
        {
            Console.WriteLine("Initializing Process Variable....");
            P = new System.Diagnostics.Process();
            Console.WriteLine("Setting startup parameters:");
            P.StartInfo.FileName = "command.exe";
            Console.WriteLine("\tFilename: " + P.StartInfo.FileName);
            P.StartInfo.Arguments = "-D";
            Console.WriteLine("\tArguments: " + P.StartInfo.Arguments);
            P.StartInfo.CreateNoWindow = false;
            Console.WriteLine("\tCreate No Window: " + P.StartInfo.CreateNoWindow);
            P.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
            Console.WriteLine("\tWindow Style: " + P.StartInfo.WindowStyle);
            P.StartInfo.UseShellExecute = false;
            Console.WriteLine("\tUse Shell Execute: " + P.StartInfo.UseShellExecute);
            P.StartInfo.RedirectStandardInput = true;
            Console.WriteLine("\tRedirect Standard Input: " + P.StartInfo.RedirectStandardInput);
            P.StartInfo.RedirectStandardOutput = true;
            Console.WriteLine("\tRedirect Standard Output: " + P.StartInfo.RedirectStandardOutput);
            P.StartInfo.RedirectStandardError = true;
            Console.WriteLine("Redirect Standard Error: " + P.StartInfo.RedirectStandardError);
            Console.WriteLine("\tGod Mode: " + GodModeOn);
            if (GodModeOn)
            {
                Console.WriteLine("\tConfiguring GodMode....");
                P.StartInfo.UserName = "Admin";
                P.StartInfo.Password = new System.Security.SecureString();
                foreach (char C in "123456".ToCharArray())
                {
                    P.StartInfo.Password.AppendChar(C);
                }
                Console.WriteLine(GodMode);
            }
            Console.Write("Starting process....");
            try
            {
                P.Start();
            }
            catch (System.ComponentModel.Win32Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.WriteLine("Done");
            Console.WriteLine("Process started at: " + P.StartTime);
            Console.Write("Redirecting streams....");
            Out = P.StandardOutput;
            In = P.StandardInput;
            Err = P.StandardError;
            In.WriteLine("@Echo off");
            In.WriteLine("Echo …
Xcelled194 28 Junior Poster in Training

Put this in the TextChanged event of the textbox.

If TextBox1.Text.Contains("-") Then
Msgbox ("Invalid!")
End If

Or if you need something Immediate, look into the KeyDown Event