That's weird, because if you type help, you will get the help message.
That's weird, because if you type help, you will get the help message.
Hi, how would I make a program that gets input from a user, sends it to a program with popen(), gets the output, and repeats this until the program ends? I have tried, but I only get part of the output, and when I type "exit", it won't end the program.
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
FILE *fp = popen("cmd.exe", "r+" );
char buff[50];
char command[50];
while (fp != NULL)
{
while ( fgets( buff, sizeof buff, fp ) != NULL )
{
cout << buff;
}
cin.getline(command, sizeof command);
fputs(command, fp);
}
pclose( fp );
getch();
}
From this, I only get "Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp." when it starts, while I should also be getting the "C:\documents and settings\...." after it.
Thanks salem it worked
How could I "fork a new process and run the program in that new process and pipe or redirect the output of the child process as an input to the parent process"?
Hi, I need to get the output of a program called with the system() function. How would I do this?
Yes! It works! Thank you.
That's weird. It works for me. I'll try doing what you said.
It's not program1.exe, I made a mistake. It's project1.exe.
It can compile the input box dialog here: http://www.codeproject.com/KB/dialog/w32inputbox_1.aspx. That uses resources, so I don't think that's the problem. If you don't have a code project account, I have attached the files. The dev-c++ compiled file is program1.exe.
Hi, I have been trying to make a dialog, but I keep getting an error. I'm using Dev-C++ 4.9.9.2, and I get this error "[Resource error] syntax error". Here's my code for the dialog:
IDD_CONNECT DIALOG DISCARDABLE 0, 0, 300, 250
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Connect"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Connect",IDOK,174,18,50,14
PUSHBUTTON "Cancel",IDCANCEL,174,35,50,14
GROUPBOX "Connect Information...",IDC_STATIC,7,7,225,52
CTEXT "Enter the host/IP to connect to and click connect",
IDC_STATIC,16,18,144,33
END
Thanks. I thought it was that, but I wasn't sure. Also, I like <conio.h>.
Hi, I have been making a program that encrypts files. It works, but it compresses them. It only does it a little bit, but it does. It's weird. Why is it doing this?
I have attached a zipped folder with the code, binary, an encrypted file, and the original file. The key to decrypt the file is "hello" without quotes. Once you decrypt the included file, you'll see that they are now the same size.
A good book that I have recently bought is Programming Windows Fifth Edition by Charles Petzold. It talks about using the Win32 API. It also has code examples and an accompanying CD. It's like $60, but I got mine used for $30 on www.amazon.com.
I figured it out, you have to include #include <commctrl.h>, link with the comctl32 library, and put InitCommonControls() in your WM_CREATE message handler. Then you can get on a command line and edit your program with the one I mentioned above (http://www.codeproject.com/KB/cpp/AddXpStyle.aspx).
HI, I have been wondering how to make a program with the XP style buttons, edit boxes, etc. in it. I have made a GUI, but it's ugly. How can I make the controls look like the ones on say, a windows property sheet or something like that? I have tried the tutorial on http://www.codeproject.com/KB/cpp/AddXpStyle.aspx, but it ERASED ALL OF MY CONTROLS.
If you're lazy and on windows:
system("shutdown -r");
Thanks, I just wanted to make sure I wasn't learning something that I couldn't use.
Never mind about the CD files. I got them.
Hi, I have bought Programming Windows Fifth Edition by Charles Petzold. I was wondering if there are any differences between the Win32 API talked about in this book and the one that applies to Vista or anything newer than Windows 2000. Also, my book didn't come with the CD (I got it used), so could someone post a link or attach the files from it?
Hi, I have been making a macro building program. I am trying to handle mouse events right now. I have made a program that hooks the mouse, then puts information into a text file which is then read by another program. The recorder writes the delay in milliseconds, so the events don't just happen at one time. It then writes the type of the event. Then it writes the other information like X and Y, right mouse button, wheel, intensity, etc. . I have no idea if this is a good way to do this or not, or how to read the file so I can simulate mouse events. Please help.:icon_neutral:
The code is attached. I'm using Dev-C++ 4.9.9.2.
Here is some output from the program that records the mouse:
1922 MMOVE 530 437
1938 MMOVE 529 437
3078 MWHEEL 120
7422 MDOWN R
7594 MUP R
11031 MMOVE 529 436
11094 MMOVE 529 435
11172 MMOVE 529 435
11188 MMOVE 529 434
11250 MMOVE 529 434
11860 MMOVE 528 434
11875 MMOVE 528 434
11953 MMOVE 527 434
12547 MDOWN L
12625 MUP L
Thanks for the tips!
Hi, I'm making a website. I want it to look professional. I don't want to use templates because I think of that as cheating. I want to be able to make one myself. Whenever I make a web page, it doesn't look very good. If anyone has any tips. Please tell me.:icon_question:
Nevermind, i got it! I had an old libmysql.dll in my C:\windows\system32 directory. I deleted it and it worked perfectly.
Hi, I have been trying to get MySQL to work on my apache server with PHP on it. My Apache
version is 1.3.29 and my PHP version is 5.0.0RC2. I'm also running Windows XP Professional SP2 32 bit. I tried modifying the php.ini file to load the php_mysql.dll, but I keep getting an error whenever I restart Apache. My Apache directory is C:\Program Files\Apache Group\Apache\, and my PHP directory is C:\Program Files\Apache Group\Apache\PHP\. The directory with the dynamic link libraries (dlls) in it is C:\Program Files\Apache Group\Apache\PHP\ext\. The error pops up three times, and then Apache starts, and I can view my server with IE 7.
I have attached my php.ini from my %SYSTEMROOT% directory as well as a picture of the error.
Please help!:-/
[PHP]
;;;;;;;;;;;;;;;;;;;
; About this file ;
;;;;;;;;;;;;;;;;;;;
;
; This is the recommended, PHP 4-style version of the php.ini-dist file. It
; sets some non standard settings, that make PHP more efficient, more secure,
; and encourage cleaner coding.
; The price is that with these settings, PHP may be incompatible with some
; applications, and sometimes, more difficult to develop with. Using this
; file is warmly recommended for production sites. As all of the changes from
; the standard settings are thoroughly documented, you can go over each one,
; and decide whether you want to use it or not.
;
; For general information about the php.ini file, please consult the php.ini-dist
; file, included in your PHP distribution.
;
; This file is different from the php.ini-dist file in the fact that it features
; different values for several directives, in order to improve performance, while
; possibly breaking compatibility with the standard out-of-the-box behavior of
; PHP 3. Please make sure you read what's different, and modify your scripts
; accordingly, if you decide to use this file instead.
;
; - register_globals = Off [Security, Performance]
; Global variables are no longer registered for input data (POST, GET, cookies,
; environment and other server variables). Instead of using $foo, you must use
; you can use $_REQUEST["foo"] (includes any variable that arrives through the
; request, namely, POST, GET and cookie variables), or use one of the specific
; $_GET["foo"], $_POST["foo"], $_COOKIE["foo"] or $_FILES["foo"], depending
; on where the input originates. Also, you can look at the
; import_request_variables() function.
; Note that register_globals is going to be depracated (i.e., turned off by
; default) in the next version of PHP, because it often leads to security bugs.
; Read http://php.net/manual/en/security.registerglobals.php for further
; information.
; - display_errors = Off [Security]
; With this directive set to off, errors that occur during the execution of
; scripts will no longer be displayed as a part of the script output, and thus,
; will no longer be exposed to remote users. With some errors, the error message
; content may expose information about your script, web server, or database
; server that may be exploitable for hacking. Production sites should have this
; directive set to off.
; - log_errors = On [Security]
; This directive complements the above one. Any errors that occur during the
; execution of your script will be logged (typically, to your server's error log,
; but can be configured in several ways). Along with setting display_errors to off,
; this setup gives you the ability to fully understand what may have gone wrong,
; without exposing any sensitive information to remote users.
; - output_buffering = 4096 [Performance]
; Set a 4KB output buffer. Enabling output buffering typically results in less
; writes, and sometimes less packets sent on the wire, which can often lead to
; better performance. The gain this directive actually yields greatly depends
; on which Web server you're working with, and what kind of scripts you're using.
; - register_argc_argv = Off [Performance]
; Disables registration of the somewhat redundant $argv and $argc global
; variables.
; - magic_quotes_gpc = Off [Performance]
; Input data is no longer escaped with slashes so that it can be sent into
; SQL databases without further manipulation. Instead, you should use the
; function addslashes() on each input element you wish to send to a database.
; - variables_order = "GPCS" [Performance]
; The environment variables are not hashed into the $HTTP_ENV_VARS[]. To access
; environment variables, you can use getenv() instead.
; - error_reporting = E_ALL [Code Cleanliness, Security(?)]
; By default, PHP surpresses errors of type E_NOTICE. These error messages
; are emitted for non-critical errors, but that could be a symptom of a bigger
; problem. Most notably, this will cause error messages about the use
; of uninitialized variables to be displayed.
; - allow_call_time_pass_reference = Off [Code cleanliness]
; It's not possible to decide to force a variable to be passed by reference
; when calling a function. The PHP 4 style to do this is by making the
; function require the relevant argument by reference.
;;;;;;;;;;;;;;;;;;;;
; Language Options ;
;;;;;;;;;;;;;;;;;;;;
; Enable the PHP scripting language engine under Apache.
engine = On
; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
zend.ze1_compatibility_mode = Off
; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On
; Allow ASP-style <% %> tags.
asp_tags = Off
; The number of significant digits displayed in floating point numbers.
precision = 14
; Enforce year 2000 compliance (will cause problems with non-compliant browsers)
y2k_compliance = On
; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).
output_buffering = 4096
; You can redirect all of the output of your scripts to a function. For
; example, if you set output_handler to "mb_output_handler", character
; encoding will be transparently converted to the specified encoding.
; Setting any output handler automatically turns on output buffering.
; Note: People who wrote portable scripts should not depend on this ini
; directive. Instead, explicitly set the output handler using ob_start().
; Using this ini directive may cause problems unless you know what script
; is doing.
; Note: You cannot use both "mb_output_handler" with "ob_iconv_handler"
; and you cannot use both "ob_gzhandler" and "zlib.output_compression".
;output_handler =
; Transparent output compression using the zlib library
; Valid values for this option are 'off', 'on', or a specific buffer size
; to be used for compression (default is 4KB)
; Note: Resulting chunk size may vary due to nature of compression. PHP
; outputs chunks that are few handreds bytes each as a result of compression.
; If you want larger chunk size for better performence, enable output_buffering
; also.
; Note: output_handler must be empty if this is set 'On' !!!!
; Instead you must use zlib.output_handler.
zlib.output_compression = Off
; You cannot specify additional output handlers if zlib.output_compression
; is activated here. This setting does the same as output_handler but in
; a different order.
;zlib.output_handler =
; Implicit flush tells PHP to tell the output layer to flush itself
; automatically after every output block. This is equivalent to calling the
; PHP function flush() after each and every call to print() or echo() and each
; and every HTML block. Turning this option on has serious performance
; implications and is generally recommended for debugging purposes only.
implicit_flush = Off
; The unserialize callback function will called (with the undefind class'
; name as parameter), if the unserializer finds an undefined class
; which should be instanciated.
; A warning appears if the specified function is not defined, or if the
; function doesn't include/implement the missing class.
; So only set this entry, if you really want to implement such a
; callback-function.
unserialize_callback_func=
; When floats & doubles are serialized store serialize_precision significant
; digits after the floating point. The default value ensures that when floats
; are decoded with unserialize, the data will remain the same.
serialize_precision = 100
; Whether to enable the ability to force arguments to be passed by reference
; at function call time. This method is deprecated and is likely to be
; unsupported in future versions of PHP/Zend. The encouraged method of
; specifying which arguments should be passed by reference is in the function
; declaration. You're encouraged to try and turn this option Off and make
; sure your scripts work properly with it in order to ensure they will work
; with future versions of the language (you will receive a warning each time
; you use this feature, and the argument will be passed by value instead of by
; reference).
allow_call_time_pass_reference = Off
;
; Safe Mode
;
safe_mode = Off
; By default, Safe Mode does a UID compare check when
; opening files. If you want to relax this to a GID compare,
; then turn on safe_mode_gid.
safe_mode_gid = Off
; When safe_mode is on, UID/GID checks are bypassed when
; including files from this directory and its subdirectories.
; (directory must also be in include_path or full path must
; be used when including)
safe_mode_include_dir =
; When safe_mode is on, only executables located in the safe_mode_exec_dir
; will be allowed to be executed via the exec family of functions.
safe_mode_exec_dir =
; Setting certain environment variables may be a potential security breach.
; This directive contains a comma-delimited list of prefixes. In Safe Mode,
; the user may only alter environment variables whose names begin with the
; prefixes supplied here. By default, users will only be able to s
Check out www.cplusplus.com. It's filled with information about file IO, strings, user input, and lots more. You might not want to make a GUI if you are very new to C++ and OOP.
I'm using the GMP library which works great.
Thanks for your help! Also, marco93, It's only 1 picture, i'm not going to take 5000. And, it works so i'm happy. =)
I started out with visual basic, so a GUI game of rock paper scissors would probably be out of the question. When I started C++, it took me a long time to get the hang of it. One of the first things I made was a prime number generator. You could probably search forums and see a thread that I started about it. That was a long time after I started though. I just wanted to make it faster. You will definitely need the internet. A LOT. If you start trying to make GUIs using the win32 API (not visual C++), there is a lot of complicated code involved. The internet is like the best resource. Once you get going, it will get a lot easier and you will understand it more.
Hi, this works for notepad, so i think it'll work for msn. Modify it a little and try it.
#include <windows.h>
int main()
{
char buffer[MAX_PATH];
char *message = "hello";
sprintf(buffer, "%s", message);
//GetWindowText(hwContact, szContact, 256);
//strcpy(&szContact[strlen(szContact)], " - Conversation");
//GetWindowText(hwMsg, szMsg, 256);
//strcpy(&szMsg[strlen(szMsg)], "");
HWND fcContact = FindWindow(NULL, "Untitled - Notepad");
ShowWindow(fcContact, SW_SHOWMAXIMIZED);
SetForegroundWindow(fcContact);
//FindWindowEx( hTray, NULL, "Button", NULL);
SendMessage(FindWindowEx(fcContact, NULL, "Edit", NULL), WM_SETTEXT, 0, (LPARAM)buffer);
return 0;
}
Hi, I am making a simple screen shot program. I need to be able to capture the entire screen, or if possible, a region of the screen (like a rectangle from point (25, 60) to (300, 456)). I also need to be able to save it to a bitmap file. I read a tutorial, but it only said how to save black and white bitmaps. I need them to be in color.
Not really. I tried more than once, why would it fail every time?
Hi, i have made a simple program that gets all of the running processes on a computer and gets the text from their windows. It works, but sometimes it gives the wrong text. For example, i have notepad open, and it doesn't say the right text. To compile, you have to link it with the psapi library.
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <psapi.h>
#include <conio.h>
#include <iostream>
using namespace std;
int main()
{
SetConsoleTitle("Process list");
DWORD ProcessesIDs[50], cbNeeded, cProcesses;
unsigned int i;
TCHAR szProcessName[50] = TEXT("<unknown>");
if (!EnumProcesses( ProcessesIDs, sizeof(ProcessesIDs), &cbNeeded ))
return 0;
cProcesses = cbNeeded / sizeof(DWORD);
for ( i = 0; i < cProcesses; i++ )
{
HANDLE hProcess =
OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ, FALSE, ProcessesIDs[i] );
if (NULL != hProcess )
{
GetModuleBaseName( hProcess, NULL,
szProcessName, sizeof(szProcessName)/sizeof(TCHAR) );
}
HWND h = GetTopWindow(0 );
char WindowText[256];
while (h)
{
DWORD pid;
DWORD dwTheardId = GetWindowThreadProcessId( h,&pid);
if (pid == ProcessesIDs[i])
{
GetWindowTextA(h, WindowText, 256);
break;
}
h = GetNextWindow(h , GW_HWNDNEXT);
}
_tprintf(TEXT("Process name: %s, PID: %u \n"),
szProcessName, ProcessesIDs[i]);
_tprintf(TEXT("Window Text: %s\n\n"), WindowText);
CloseHandle(hProcess);
}
getch();
}
Here's the output:
Process name: <unknown>, PID: 0
Window Text:
Process name: Æ’unknown>, PID: 4
Window Text:
Process name: smss.exe, PID: 464
Window Text:
Process name: smss.exe, PID: 532
Window Text:
Process name: winlogon.exe, PID: 556
Window Text:
Process name: services.exe, PID: 600
Window Text:
Process name: lsass.exe, PID: 612
Hi, I recently watched the movie Iron Man. While making his first suit, Tony Stark apparently is using C++ on the laptop in the background. Is this C++ and if not what is it?
It needs to be able to hold about one quintillion.
Hi, is there a data type larger than unsigned long long int except double? I don't want double or float because I need to keep it as precise as possible. I also need it to be able to do modulus. How would I do this?
Thanks for your help!
ZOKOR, I'm all set on putting safedisc on my computer:
1. I don't have a DVD burner.
2. I hate putting disks back in all the time to run programs. Look at this: http://en.wikipedia.org/wiki/SafeDisc#Operation
Thanks caperjack. I installed Cute CD DVD Burner before you posted a reply, and it said that I can only read DVDs.
Will an Apple iBook G4 be able to write to DVDs and if so burn an ISO image to them?
That's most likely the case. Ill attach a picture of my drive. Is there a way I can burn a DVD without buying a new one?
Yes, i can burn pictures, music, and ISO images to a CD-R disk.
IsoBuster didn't work. It just said "No media present". I updated my IDE ATA/ATAPI Controller: SiS 5513 IDE UDMA Controller. That didn't work. My AOPEN COM5232/AAH PRO firmware is up to date (R.1.08). I have no idea what to do.........
I have 2 different DVD brands that bothwon't work: Sony DVD+RW, and Maxell DVD-R.
I will try the isobuster and see if it works.
I have tried to do it on 2 other computers. It still won't work, so I don't think it's the burner.
No, windows explorer and every other program I use, including ISO Recorder, says that there's no disk in. Which program should I use? I have MagicISO. I can't get nero because I have dial-up, so that would take forever. I checked my drive firmware. It's completely up to date. Also, another detail I left out: whenever I put the disk in, Windows slows down a lot.
I'm using ISORecorderV2RC1
Hi, whenever I put a blank DVD-R or RW disk into my drive, Windows will say it's not there. The cursor turns into a little CD, but whenever I try to burn an ISO image or any type of file onto it, it says that it's not in. I looked on microsoft.com, and it said to get a hotfix for udfs.sys. Would this help me?
I am using:
Operating System:
Windows XP Professional SP2
DVD/CD-ROM Drive:
AOPEN COM5232/AAH PRO
I have done FTP before and it didn't block it. That's the only time I've seen it try to block it.
I was doing a simple ftp and look what I found! Look at the attachment!