|
-
Aug 5th, 2001, 09:35 AM
#1
Thread Starter
Fanatic Member
Strings in C
I am trying to make my .exe file as small as possible and someone suggested using C instead of C++. In one part of my program I need to get input from the keyboard and use it in a Windows API function (FindWindow()). How acn I accomplish the same thing in C? I attached what I have so far.
Alcohol & calculus don't mix.
Never drink & derive.
-
Aug 5th, 2001, 11:01 AM
#2
Use printf() and scanf().
Code:
#include <windows.h>
#include <stdio.h>
int main()
{
LPSTR sName;
printf("Type in the name of the window you wish to show or hide:");
scanf("%s", sName);
HWND h = FindWindow(NULL, sName);
if (h == NULL)
MessageBox(NULL, "Could not find window", "Error", MB_OK | MB_ICONERROR);
else
{
if(!IsWindowVisible(h))
ShowWindow(h, 1);
else
ShowWindow(h, 0);
}
return 0;
}
-
Aug 5th, 2001, 11:35 AM
#3
Thread Starter
Fanatic Member
If I use that the program crashes after I enter the window name.
Alcohol & calculus don't mix.
Never drink & derive.
-
Aug 6th, 2001, 06:06 AM
#4
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 6th, 2001, 09:41 AM
#5
Thread Starter
Fanatic Member
That doesn't work either, it says "Could not find window" if there are more than one word...
Alcohol & calculus don't mix.
Never drink & derive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|