Comatose 290 Taboo Programmer Team Colleague

I'm not sure how using session to store the invalid attempt count works, but it's sounding like a DoS waiting to happen. What if I (not legit user) want to stop you (legit user) from accessing your account? I guess I could try three times to get your password (and get it wrong). Then you (legit user) will be locked out of your own account :icon_eek:

Comatose 290 Taboo Programmer Team Colleague

Once of the biggest problems you are going to face... is how yellow is yellow? From this site alone I pulled up 7 different values of "yellow". So how yellow is your slider bar's yellow.... is it pure 255, 255, 0? I've got some basic code that will retrieve the pixel color under the mouse, which needs to modified to include a for loop for your x coordinate, a modified number for the y coordinate, and a pretty good value for yellow. You could certainly make it scan for a range of "yellow values" say between 170 to 255 red, 170 to 255 green and 0 to like 100 blue, but with ranges like that you start to significantly increase your possibility of false positives.

Comatose 290 Taboo Programmer Team Colleague

Hmmm, I'm going to guess (since you didn't mention what the problem was) that it's skipping to the bottom of everything after you input the letter. Yeah. The problem is that you are doing a cin >> type double (yeah, LetterGrade_1 is a double, not a char) so when you type in a letter, and it tries to read it into a variable that is a double.... whoopsie. Try it when you input numbers.... is the result different?

Comatose 290 Taboo Programmer Team Colleague

You could do it with IPTables.... just set the rule to not allow outgoing traffic to a given site. Set it up with a script in a cron job, to handle what to block and when..

Comatose 290 Taboo Programmer Team Colleague

Sounds like a fun homework assignment..... what code do you have so far?

Comatose 290 Taboo Programmer Team Colleague

ah, yes. You could take the char array, and convert it to string, and then compare. While a bit of a pain I suppose:

std::string tmpvar(recv_data);
if (tmpvar.compare(qns) == 0)

I think you could just do a simple == at that point though. if (tmpvar == qns) {

Comatose 290 Taboo Programmer Team Colleague

it's actually on the link that you provided. If you look carefully, they are using ShellExecuteEx there. So, do that, and adjust it to your .bat file.

Comatose 290 Taboo Programmer Team Colleague

Sorry about that. I've taken the source code of the link you posted, and tried it with that... made some modifications. Now it should work fine.

iamthwee commented: Erebus, wtf is up with rick ashley arrrrgh!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -4
Comatose 290 Taboo Programmer Team Colleague

Eewww, Slove your own bug.

Comatose 290 Taboo Programmer Team Colleague

How is the linker supposed to know about the object/variables?

Comatose 290 Taboo Programmer Team Colleague

It is important to mention here, that it is easy enough to use findwindow and setwindowtext to change the caption of the start button, but it is more important to mention, that it doesn't show up until you put your mouse over it (force it to animate [change to lighter green] in XP), and worse yet.... even after you change it, as soon as it's parent (Shell_TrayWnd) gets any kind of focus again, the first thing it will do is change the caption BACK to start. So, unless you plan to devour system resources by polling the start button's caption and changing it when it needs it.... you'll have to edit explorer.exe and change it in there. You can make it effective if you lock the taskbar, so that the Shell_TrayWnd isn't easily accessible with the mouse, but this will still cause some issues for you.

Comatose 290 Taboo Programmer Team Colleague

If it is a system call (such as shell, or wsh.run) and it is blocking (ie, the program is waiting for shell or wsh.run to finish the externally running program), you need a much more complicated method involving things like waitforsingleobject...

Comatose 290 Taboo Programmer Team Colleague

Not with a character array (that I know of). In order to get all the wonderful toys, you need to use std::string.
I suppose you could set indice 0 to '\0'....

Comatose 290 Taboo Programmer Team Colleague

you wouldn't change open to runas..... open is the "command" basically, that you are doing. What do you want to do with this file? Open it. Just like if I double clicked on it. calc.exe is a program in windows (all versions passed like 2.0). Runas is a program in vista. So replacing open with runas isn't going to work.... it's the wrong parameter. You need to replace calc.exe with runas, and somehow pass like calc.exe (and all the switches) to the parameters argument of shellexecute. It may be easier to use shellexecuteex as in the provided link above... so I guess something like this (not tested):

ShellExecute (NULL, "open", "runas", "test.bat", "c:\\", SW_NORMAL);

But based on the fact that you are in vista, and require elevated privs, I suggest using the shellexecuteex.

Comatose 290 Taboo Programmer Team Colleague

You can do the same with classes. In C++ a struct is a class. The only difference is that a struct's data members are public by default... while a class's are private by default.

Comatose 290 Taboo Programmer Team Colleague

memset (b, '0', 100); ?

Comatose 290 Taboo Programmer Team Colleague

hmmm... works great in vb 2008 express.... which version are you using (and what error does the IDE give you?)

Comatose 290 Taboo Programmer Team Colleague

Oh, yeah. mobjCmd isn't defined. From what I can see, you are using mobjCmd... but nowhere in your code did you dim mobjcmd, and also, I don't see where you set mobjcmd = something.

Comatose 290 Taboo Programmer Team Colleague

First... I wouldn't make the text file in that way. I'd use a delimiter. Such as:

Hello, How are you?:I'm fine.

This saves you the hassle of having to guess where the client sentence ends and the server sentence should begin. You already know... it's because of the :. I suppose the same could be said about the ?, but what if it now becomes a statement? Using a standard delimiter makes life that much easier.
As far as the code goes... it looks to me like your second strtok might throw things off result = strtok(NULL, "?.!"); doesn't match up with your first strtok, which is splitting by " ", not ?.!. You said above that there seems to be a compilation error... if so, what is the error?

Comatose 290 Taboo Programmer Team Colleague

....

Comatose 290 Taboo Programmer Team Colleague

hmmm, trying moving .MoveNext to the outside of the loop.

Comatose 290 Taboo Programmer Team Colleague

Depends on the OS. I would probably use WXWidgets (cross platform), fltk (cross-platform), or QT (cross-platform). You can create a pretty nice interface with these libraries. Borland C++ is a compiler (program that converts c++ source code to machine code). You can use something like code::blocks (WITH MINGW). It's a pretty good IDE/Compiler. Since the question is about shell scripting though.... how would you make an interface with shell scripts?

Comatose 290 Taboo Programmer Team Colleague

Or use.. execlp(...)

Which I believe is *nix only.....

Comatose 290 Taboo Programmer Team Colleague

I'm not going to say that shell script can't... but I will say it's probably not a great idea. I mean, assuming the proper rights, you might be able to use simple output redirection to sends the contents of the song directly to the output device. This depends on a huge number of factors, and the song will likely need to be converted first... but it could be done I guess.
Personally, I'd do it in C++, by using some of the mad open source libraries out there...... it would be pretty simple really.... learn a few types, make a few classes, play a few songs.

Comatose 290 Taboo Programmer Team Colleague

that code isn't VB6 at all. It's vb.net. If you want to port it to vb6, you should simply re-write it. The languages/code are that different. If you need help on a re-write, we can help you.

Comatose 290 Taboo Programmer Team Colleague

well, it's included in the windows.h, so try this:

#include <iostream>
#include <windows.h>
int main(int argc, char **argv)
{
     ShellExecute(NULL, "open", "C:\\windows\\system32\\calc.exe","", "C:\\", SW_NORMAL);
     return 0;
}

EDIT: Negative. ShellExecute is NOT C++.... ShellExecute is a windows function that can be called from any language with the ability to use windows API's (C++ is such a language). This is windows specific, and won't work in *nix or Mac.... and is not a standard.

Comatose 290 Taboo Programmer Team Colleague

// is a comment, not \\, but even so, if it were in quotes it wouldn't matter. This is ok:

std::string x = "//hello world";
Comatose 290 Taboo Programmer Team Colleague

in windows can you use ShellExecute, which is an API call that will allow you to spawn an application.

Comatose 290 Taboo Programmer Team Colleague

if you know the caption / title of the window you can try this: appactivate "title of window here"

Comatose 290 Taboo Programmer Team Colleague

Looks to me like you are mixing a couple concepts. For starters, you have at the top, your function prototypes... those say that getStudentCount is returning no value to the main function. However, when you actually code the function, you say that it is returning an int. Now, in the code for the getStudentCount function, you also use a pointer to allocate a new array on the heap (stuArray)... then you try to return this pointer to an int. However, your function is trying to just return an int.... not a pointer to one. I'm not sure why you also pass the students variable to the function, I can only image you want to use that to keep track of the student count for your loop in main... but in order to do that, it either needs to be a pointer, or a reference, so that the cin in getStudentCount can modify it. If you don't make getStudentCount return a pointer (which it doesn't so far, but tries to) then you will have a memory leak (your program allocates memory, and loses the pointer to it).

Also, it looks to me as though you are confusing some concepts. Global variables exists throughout the entire program... all functions, etc. However, a number of your variables are NOT global, they are local. You see, you declare stuArray in getStudentCount, and then try to use it after you jump back to main. You can't do that. Once the closing brace (curly bracket) …

Comatose 290 Taboo Programmer Team Colleague

hmmm \b?

cikara21 commented: haha.. +1
Comatose 290 Taboo Programmer Team Colleague

What you need is the API call (assuming windows here... *nix let's you do it without some kind of voodoo) MoveFileEx. MoveFileEx is an api called (I believe declared in windows.h) that allows you to move a file, even if the file is in use. This doesn't actually take effect until you reboot the machine, but the API flags the file for move. If you choose null as a destination, it deletes the file. The prototype is:
MoveFileEx(sSourceFile, sDestFile, MOVEFILE_DELAY_UNTIL_REBOOT).

Hope that helps.

Comatose 290 Taboo Programmer Team Colleague

I guess I'm slightly confused about what you are trying to do, so let me try this:
a web server is a program running on a computer somewhere. One computer can run many servers (I have a server that runs a web page (web-server), runs a mail server program, runs an irc server program, a DNS server program, and an SVN server program). This would cause some kind of problem, but each server runs in a different slot on the network connection called a port. These ports are represented by numbers. For example, if I connect to that remote computer, and tell it to use port 80, then it knows to use the web server (assuming the web server is running on port 80... this is not a requirement, just a stern suggestion from IANA). Now, I tell my web browser to connect to google.com. My browser knows to try to connect to port 80, on google.com. When my web browser connects to google.com, it says "hey google, how about you get me this file." Sometimes that file contains HTML (web page code). Sometimes that file is a .txt file... and sometimes it's a file that the web browser doesn't know about... so it asks you to download it. The web-server doesn't care... it has no idea what is in the file....and it doesn't want to know. It simply accepts the connection on the port, sees if the file you requested exists... if so, it opens it …

Comatose 290 Taboo Programmer Team Colleague

Wait, so even a valuable addition in 2009 to a thread in 2004 is welcome?

Comatose 290 Taboo Programmer Team Colleague

Aaahh.

Ok, you need to look into using sockets (winsock or socketwrench... I like socketwrench better, but winsock will get the job done). Then, you need to connect to the web server with the socket... chances are it will be running on port 80, but this is not a requirement. Once you connect to the socket, you need to pass it an "HTTP Request Header." That header would include the server's path (relative to the web server) to the file. Then, the webserver would return a mime header (HTTP Response Header), that you would need to basically check (in order to make sure it's not a 404 error, or some nonsense). If the response is ok (like 200) after the 2 line breaks would start the actual file. You save that in a file with your open command, and call it a day. The process might be something more like "read from socket, write to file, read from socket, write to file", but the idea is the same.

There is an easier method if you follow this link through to it's conclusion (or I guess jump to the last post). This should give you a pretty good idea of what's happening.

Comatose 290 Taboo Programmer Team Colleague

I think it should be in the rules, that posting to old threads is a no no. It's not actually considered a member rule... just poor etiquette. So, if I wanted to be an obnoxious ass (more so than I am already), I could just start responding to old threads all over the place. Granted, it would destroy any kind rep that exists, but I could point out "it's not considered a rule". Why not just add it in there under like "Keep it spam free"?

I just mean, it's kind of a pain to bark at people about posting to old threads (yes, I know about the cute little text by the post box... but they obviously don't.) when I have nothing to direct them to about their behavior.

Comatose 290 Taboo Programmer Team Colleague

usually you don't. Unless you can download the appropriate cab-files from a *beeeeeeeep* site or a *beeeeeeeeep* that has it on his or her computer.

Comatose 290 Taboo Programmer Team Colleague

when you say "the remaining contents should be the same" do you mean, in file1 (ALL:FILE1) it should have just ALL:FILE1, AND the rest of the file (with the exception of ALL:FILE2, and ALL:FILE3, etc) or .... what?

Comatose 290 Taboo Programmer Team Colleague

Dude... did you not read my post about the thread being old.... give it a rest people.

Comatose 290 Taboo Programmer Team Colleague

I'm assuming that by "downloaded and installed" you mean that the web-server installs the files/applications to the client/local computer. If that is case, then no. This never happens. A Web-server is a program that runs on a server.... what it is not... is HTML, javascript, ActiveX, or any of the other scripting/programming languages that it (the webserver) dishes out. That said.... most of the time, these web-sites that infect your system, do so by finding flaws (exploits) in the web-browser's code. So, someone studies, say, Internet Explorer's .dll file (or perhaps the .exe, depending) and finds out exactly how it deals with, I dunno, javascript. Once they know how it deals with javascript, they can figure out where mistakes were made (or if it was simply careless programming.... Microsoft). Now they can carefully design a javascript, which executes onload, and makes use of that mistake or careless programming.

Comatose 290 Taboo Programmer Team Colleague

if it's a normal text file, I would cut it by the lines. Count how many lines there are, divide it by 4, and write them into new files. I'd probably add a byte or a line to the end of the file as the tag. The only thing I see as a problem, is if someone types a really long ass line without a newline.... then you would kind of have to go by bytes. In order to avoid that entire mess, you could just do it as byte from the beginning.

Comatose 290 Taboo Programmer Team Colleague

You are passing no parameters to the Point class's constructor. It expect 3 floats, during instantiation (Point myLocation). You need to give it three floats.

Comatose 290 Taboo Programmer Team Colleague

you are using "new" right? So, it's dynamically allocating memory right? Where is your pointer to the new object in memory?

int main()
{
      X *newX = new X();
}

EDIT: *Snaps His Fingers* Beat me to it!

Comatose 290 Taboo Programmer Team Colleague

I trust O'Reilly significantly more than wikipedia. I also read on MSDN (will post when I get home) that it's the API calls and programs that do the translation, not NTFS Native.

Comatose 290 Taboo Programmer Team Colleague

Thats DOS (or other shell), not Windows. DOS uses forward slashes as switches, so you can't use them in directory paths. But Windows does fully support them. Its Windows itself that translates forward slashes into backslashes. Try using backslashes in Unix directry paths with perl or python and see what happens.

Oddly enough, the above posted (with the suggestions to try cd / and cd /windows and cd "/documents and settings") was tested in windows XP SP1. I went to start... run, and typed in cmd. Once the window was up, I typed cd /, and hit enter. While XP didn't completely flip out, it certainly did not take me to the root directory (\). Then, when I typed cd /windows/system32, this most certainly did error. Try it with a known branch, such as: cd /windows/system32. No can do. Notice the second entry of the command line... gives an error. The third (using \'s) does not. The rest of the lines... none of them work either (although, the cd / doesn't error, it also doesn't work.). This is not DOS. This is cmd.exe (not command.com). However, KevinADC is right that explorer.exe (windows Desktop shell) does allow the use of / in paths (such as typing a path in my computer's location bar). The question is... is that the file system, or is that explorer.exe?

According to O'Reilly & Associates (Section 2.2.2, point / bullet number 2, and the table in 2.2.4) Some Perl modules and …

Comatose 290 Taboo Programmer Team Colleague

Hey... Wingnut. How about you not post to threads that are like 2 years old.... start a new thread.

Comatose 290 Taboo Programmer Team Colleague

So... Suzz. Let's not post to threads that are two years old.

Comatose 290 Taboo Programmer Team Colleague

I'm pretty sure windows does not support paths with / as the separator. Try this: cd / or cd /windows and then try this cd \windows . What I'm guessing happens here, is Perl (and other languages that do this, such as python) are smart enough to know that even though we hacker-esque folks use / in a path, that we really mean \, and naturally adjusts it

Comatose 290 Taboo Programmer Team Colleague

I know what web servers do, I have my own website that is partly made up of pure HTML and Javascript.

Ok, so then you also know that web servers don't maintain a persistent connection. Which means that the connection doesn't stay alive. Which means as soon as the web server is done dishing out the web page to the client (or any information to the client) it immediately disconnects. So... let's follow this scenario:
1) you connect to the web server
2) buddy connects to web server
3) web server d/c you
4) buddy tries to send you a message, and is also d/c
5) web server..... does what? Sends you a message over a broken TCP connection?

Comatose 290 Taboo Programmer Team Colleague

This thread is two years old.... please don't post to threads that are older than three months.