Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

801.

Solve : Batch to open a .pdf file?

Answer»

I'm WROTE a .bat file to open .pdf file. The problem is the .pdf file name is different everytime. So I was HOPING to write a .bat file that would open any .pdf in the folder. Is this possible?rick587.......why dont you D/L Adobe reader and forget about batch FILES ?

http://www.adobe.com/products/acrobat/main.html

Hope this helps,

dl65 Thank you. What is D/L?rick587.......Glad to hear that the free Adobe reader helped you out......

D/L = Down Load

dl65 Brainiac rescues ANOTHER 3-year-old thread! And forgets to ADVISE that paths with spaces need QUOTES. Now THAT's "elementary".

802.

Solve : Information logging Batch File?

Answer»

I'm trying to make a batch FILE that LOGS information at a prompt (in whicn you TYPE something LIKE name, age, whatever) and saves it to a .txt file. Anyone know how? thanks! "Brain" iac's way of BUMPING up his post count is to revive 3 year old threads.

803.

Solve : ejp,servlet and swing?

Answer»

hai,

I Know only basic java.
I want to study ejp,SERVLET and swing.

Can ANYBODY guideme to study all these.
What s/w i need to INSTALL and how to programe.

Thank you
EJP is here..

Servlet is here..

Swing is here..

But I THINK you will have to do the spade-work and COME back with more specific queries..

Good luck

804.

Solve : ejb,servlet and swing?

Answer» HAI,

I KNOW only basic java.
I want to study ejb,servlet and swing.

Can anybody guideme to study all these.
What s/w i NEED to INSTALL and how to programe.

Thank you
No double posting, PLEASE.
805.

Solve : ejb,servlet and swing.?

Answer»

hai,

I Know only basic java.
I want to study ejb,servlet and swing.

Can ANYBODY guideme to study all these.
What s/w i need to install and how to programe.

Thank you
Ejp is here..

Servlet is here..

Swing is here..

It's up to you to do the spade-work and POST SPECIFIC QUESTIONS when you need assistance.. Lots more help on the WWW

Good luck..
Please refrain from double posting. Your other TOPIC has been locked.

806.

Solve : fat file or ntfs??

Answer»

which FILE should i use when reformatting my pc? FAT file or ntfs file and why? any suggestions? tnxI'm pretty sure you didn't google at all.

Anyway NTFS file systems for DISK partitions on your Windows XP-based computer.


Try this ONE http://www.microsoft.com/windowsxp/using/setup/expert/russel_october01.mspxthanks.

807.

Solve : new and delete?

Answer»

What does the NEw and delete operators do in c++...
i looked thru several sites..but it made me more confused..
so can any one tell me what these two keywords do..PLZ explain in detail..
and also can anyone tell me what the
using namespace std; does and means....my advise, you should get a C++ book instead.An object created with operator new() or operator new[]() exists until the operator delete() or operator delete[]() is called to deallocate the object's MEMORY. A delete operator or a destructor will not be implicitly called for an object created with a new that has not been explicitly deallocated before the end of the program.
Using namespace std is used when you want to ACCESS objects, functions, classes, variables and all that declared inside the std namespace.
To be more specific, it allows you to refer to functions, classes, and anything else publicly available in the std namespace without the use of a qualified name.

For example

using namespace std;
cout << "Hello World\n";

as opposed to
std::cout << "Hello World\n";

The first uses an unqualifed name, the second uses a qualified name.can u GIVE an example of how to use new and delete operators with examplesi FIGURED i should find a link instead.
try this site.This is usually, in my programs, used to put new object instances on the free store rather than the stack, therefore making it easy to create objects inside separate functions.

//Stuff...
Cat *newCat = createCat(5, male, 10);
// . . .

Cat * createCat(int age, gender sex, int weight)
{
Cat newCat = new Cat(age, sex, weight);
return *newCat;
}

In the above gross oversimplification, the new function isn't necessary. But if I needed a tree of if...else if...else statements, a case block, or any other thing that would take up a lot of code space, I could do that. Whenever I don't need the new cat, I call the delete() function on it.

808.

Solve : Frequencia Fuera de Bande?

Answer»

What does this mean when it APPEARS on your COMPUTER screen.
Frequencia Fuera de BandePlease, only ONE topic per question.

809.

Solve : puzzled?

Answer»

When I start up my computer I get a small box in the middle of the screen saying
Frequencia fuera de bande. Can anyone tell me how to REMOVE this I USING a computer with windows xp
ThanksWhat language is your computer using? Are you in Spanish?

That error translates, roughly, to "Frequency outside bande" according to the dictionary.com translator. Are you using a radio, or some other device on your computer?Quote from: Dilbert on July 09, 2007, 10:42:04 AM

What language is your computer using? Are you in Spanish?

That error translates, roughly, to "Frequency outside bande" according to the dictionary.com translator. Are you using a radio, or some other device on your computer?

Wouldn't that more likely mean that his video card is configured such that the monitor can't keep up with it? Refresh rate, perhaps? Horizontal and/or vertical sync, maybe?

You're right; I totally forgot about that. Usually because I leave settings I don't fully understand alone (it works - don't touch it!), and while I sorta-understand refresh rate, it's not something I am 100% familiar with.

Did you recently upgrade your video card or monitor, or CHANGE their settings?Quote from: Dilbert on July 09, 2007, 02:07:17 PM
....and while I sorta-understand refresh rate, it's not something I am 100% familiar with.

I'm in the same BOAT - I too do not profess to know all the ins and outs of it.

I believe it is a function of what the monitor is capable of, and also the video card. If the video card is capable of a higher rate than the monitor, then the user must use the lower rate - the monitor's.

Quote
Did you recently upgrade your video card or monitor, or change their settings?

lachesis: Also, can you describe your monitor for us? Manufacturer name, model number, .... everything that identifies it. With that info, perhaps someone can find the correct settings for you.





810.

Solve : There must be a way!?

Answer»

I'm thinking about using a computer as a midi sound module. With a Sound Blaster card. I should be able to program a ROUTINE so that when I start the computer it will eventually open a program LIKE creative's keyboard and allow me to USE it without a keyboard or screen. The other option would be to not use the screen. THANKS!

811.

Solve : Visual Web Developer Create User?

Answer»

In Microsoft Visual Web Developer (using SQL and ASPX.NET) my "Create New User" form requires that the PASSWORD be 7 characters long, and contains at least ONE number.
How do I change it to 4 characters long, and no numbers?

Web Developer 2005 Express EDITION.
I have full access the the SQL server, which is on this computer. This is mainly an experement, so nothing can be damaged.

Thanks
-Zylstra

812.

Solve : Qbasic and the CTRL+C command?

Answer»

Mmm, 1988 programming

Is there a way to make it so that the CTRL+C command will not allow a QBASIC program to close?
I know it sounds menacing, but its not.

The program I was writing (for some reason, it wont load, so now I have to REWRITE it ) asks a user for the password to access a system.

If a user didn't have a password (right now, for my current version) they can press CTRL+C to bypass it.

(^^ Yes, this is one of my lame programs that I created for no reason, except for the fact that I am bored^^)

(And my solution for not using loops: Goto commands mixed with IF-THEN statements)
You can tailor the content of NoBreak.zip from the Miscellaneous section on this site, but don't forget to include some method of terminating the program.

Good luckDocumentation:

So you forgot your password, and you need a way out of it:
Press the following keys, in order:
CTRL+C+D+TAB+SHIFT
(These keys can be pressed by this order: Pinky on TAB, That one finger on D, Ring on C, and thumb on SHIFT and CTRL)
As you are holding this down, start typing the following text:
"India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great India Is Great "
and press ENTER

The CONF$ data will be reset, and the next time you restart your computer, it will allow you to enter a new password.




Another question for you experts:
How could I make a key combination activate a sub or GOTO command, for EXAMPLE:
If I wanted CTRL+H to give the command
Code: [Select]goto help or Code: [Select]call helphow would I go about doing that? Quote from: Zylstra on July 16, 2007, 08:30:44 PM

Documentation:



Another question for you experts:
How could I make a key combination activate a sub or GOTO command, for example:
If I wanted CTRL+H to give the command
Code: [Select]goto help or Code: [Select]call helphow would I go about doing that?

Am not sure what the Documentation part of your response is all about but I might just get round to trying it one fine day.

You didn't say what version of QBasic you are using but key combinations generally only allow for Gosub EXECUTION. You could call a sub from within the Gosub routine. Here is an example of CTRL+H but note this executes only when Capslock, Numlock and Shift are Off..

Code: [Select]CLS
KEY 18, CHR$(&H4) + CHR$(&H23) ' user defined key within range 15 - 25
KEY(18) ON: ON KEY(18) GOSUB 40

do ' simplest of loops to KEEP prog running
loop ' until the Ctrl+h combination is pressed


40 SHELL "type c:\windows\system32\eula.txt" ' test
END
RETURN

CHR$(&H4) is the Keyboard Flag for CTRL and CHR$(&H23) is the Scancode for the letter H.

The example has been tested using QB ver 4.5, no warranties given.

Good luck




Okay, thanks, Dusty

I have the newest version of Qbasic (1988... really new...)
So all should work well
813.

Solve : need help SAP 2 and SAP 3 Architecture plssss. help me?

Answer» PLEASE help me i need a SAP 2 and SAP 3 ARCHITECTURAL design
814.

Solve : netbean IDE 5.5 display error tail "0000"?

Answer»

init000
deps- jar000
compile000
run000
haresh000
BUILD SUCCESSFUL (TOTAL time : 0 second000

tail "000" always come after running projest
why it so !!I've never seen that in NETBEANS.
Have your tried to uninstall and reinstall.
Also updating your jre/jdk might help.

Else I think your chance for an answer would be GREATER if you try a forum dedicated to Netbeans like this one.
http://www.nabble.com/Netbeans.org-f2602.html

815.

Solve : Q-How Do I Decrease the Number of Programs Running in Background??

Answer»

How do I decrease the number of programs running in the background when I start-up the computer? I remember something about typing in Run: "config" and un-clicking the programs I do not WANT to run when starting the computer. I have XP. Thank you! My email is [REMOVED to avoid spam]What you're THINKING of is Start > Run > msconfig

Click on the Startup tab and UNCHECK the programs you don't need. Make sure you don't remove any important programs like your protection.

816.

Solve : add-in manager vb 2005 express?

Answer»

can ANYONE TELL me how to TRIGGER "add-in manager"on the menu bar. I SEEMS to be missing in the 2005 EXPRESS edition.

Thank you.

817.

Solve : NEED DOS help?

Answer»

Windows XP operating system.

I am trying to xcopy a set of files, ETC. from one dir to ANOTHER. But keep gettingthe error that the file already exists on the other dir. I do not want to DELETE these files on that dir, so what I want to do is IF the filename exists, I want to rename the file one TH second dir. Seems straightforward, but I can't GET it

818.

Solve : I'm need professional program for website advertising?

Answer»

Anybody can recomend me links to purchase private SOFTWARE for advertising internet-projects?
It's really IMPORTANT to me. Please, HELP.

THANK you all

819.

Solve : server but the file is missing?

Answer»

i am working on a server for an multiplayer online game... LOLZ... but the file called MSWINSCK.OCX i have the file here and everything but it doesnt work for some REASON. i dont know what i did lol.do you get a MESSAGE?
EG: "Failed to load control Winsock from MSWINSCK.OCX"?no it says it or one of its dependancies are missingwell i ran it on a different user account on my computer and it worked

820.

Solve : flash drive batch file help?

Answer»

i want to use a batch file to run programs off of my flash DRIVE but don't want to change the drive letter every time i plug it into a computer. I've attached what i have so far. I think i posted this in the right forum

[attachment deleted by admin]i am not sure but you may be able to use .
instead of the drive lettercan i use the name of my drive like the volume label If the batch file is on the flash drive, %~d should count as the drive letter. so i put %~d instead of F:\ or G:\ Quote from: rubiks231 on August 19, 2009, 05:59:20 PM

so i put %~d instead of F:\ or G:\
If I remember correctly then yes (otherwise it is a problem with a variable). i got it, thank youif its ok to messup the path env
at the BEGINNING of the batch file
Code: [Select]@echo off
cls
set PATH=%path%;A:\;B:\;C:\;D:\;E:\;F:\;G:\;H:\;i:\J:\;H:\:L:\
set /p A=what do you want to do:
IF '%A%' == 'pstart' GOTO pstart
IF '%A%' == 'ghost' GOTO ghost
IF '%A%' == 'internet' GOTO internet
exit

:pstart
"\USB Toolkit\PStart\PStart.exe"
pause

:ghost
"\GhostzillaCD-1.0.1-free-v1\program\Start-Ghostzilla-CD.exe"
pause

:internet
"\USB Toolkit\Tools\Internet\PortableFirefox\FirefoxPortable.exe"
pause
[/coe]
821.

Solve : program idea?

Answer»

i had this idea a while ago and tryed to do it by hand and was exhausting i WOULD like to make a program that would make a BUNCH of folders like a 4-digit combination lock so there would be folders with numbers 1-9 and in each folder folders 1-9 and so on im kinda new at PROGRAMING so some TIPS would be helpful PHP can do this. You'll need a server though.

Code: [Select]<?php

for($i=1;$i<=9;$i++)
{
mkdir("/".$i,0777);
for($j=1;$j<=9;$j++)
{
mkdir("/".$i."/".$j,0777);
}
}

?>

That should work.would it be possible to do it locally or using like c++It probably would, but sorry - I don't know C++. There are people here who can help, though.how about a batch FILE? is that possible heres the batch code
Code: [Select]for /L %%c in (0, 1, 9999) do (
md %%c
echo Creating directory %%c
)

822.

Solve : inf programming?

Answer» IVE probably put this in the wrong section but any way

im making an auto run FILE for an usb flash drive this is it at the moment

Code: [SELECT][AutoRun]
OPEN=programes/Phun/Phun/Phun.exe
ICON=programes/favicon.ICO
ACTION=start phun
LABLE=steven_1

SHELL\destroy\command=programes/destroy.bat
shell\destroy=destroy the world!
shell\count\command=programes/count.bat
shell\count=start counter
shell\test\command=programes/locker.bat
shell\test=file hidersee at the moment when the auto play box comes up only one of my custom options come up and i would like to know how to make it so i have 2 or 3 options on the autoplay box "the shell\ are not involved in this question they WORK "so can anyone help me cus i realy need it donehttp://www.phdcc.com/shellrun/autorun.htm
823.

Solve : suggestions for first moderately ambitious application??

Answer»

Hi, everybody. I've been studying C# (using Visual C# 2008 Express) for several months and I think I've got the basics down pretty well at this point, so now I want to create a moderately ambitious application to consolidate and grow my skills. Any suggestions for what kind of app would utilize the full SET of skills that would be expected from a preprofessional level STUDENT?Probably a simple word processor made with a rich text box. I learned a lot from making that, except it was in vb6. It kind of depends on what your interested in though.you can always try to make a simple game, i have learned a lot from working on my rougelike and i have just begun!Write a program that OPENS and converts images to different formats and depth.Quote from: Quantos on August 15, 2009, 05:03:03 PM

Write a program that opens and converts images to different formats and depth.
good sugjestion quantos
here is image file FORMAT REFRENCE:
http://www.martinreddy.net/gfx/2d-hi.html
824.

Solve : copy or delete my folder to a flash drive through batch file?

Answer»

just want to make a USEFUL .bat in our office so that it won't take time in deleting and copying folders.Did you okay this plan with your IT?@orig poster more details please
@QUANTOS its ok for the orig poster to make a batch file just to test but i think test at home first is bettercode pls...
copy a folder or file to a USB or floppy disc or cd.
also to delete a folder.Quote from: Quantos on August 20, 2009, 09:37:40 PM

Did you okay this plan with your IT?
yaps!!!
I know how to delete a file but I want to delete a foldercopy also if you know!!!
thanks!what about deltree
and copy C:\somefolder\*.* C:\anotherfolderok na.... tyFirst off, that ATTITUDE won't get you any joy here.Quote from: Quantos on August 21, 2009, 12:09:05 AM
First off, that attitude won't get you any joy here.

are you talking to me?No, I'm talking to the OP there.
825.

Solve : i need a debugger!?

Answer»

i decided i should probabbly start USING a DEBUGGER, and everytime i google it i find nothing helpful, so dont show me a google page, i am using bcc55, and turbo c refuses to LET me find it, so please helptry this

[attachment deleted by admin]when i TRY to OPEN it all it says is "program has invalid symbol table" are there help files i can use, and by the way it reminds me of a hex editor lolignore that message
press F7 to step the program
and it has mouse support too
also sometimes you need to give it a command such as
td
if you dont it will only debug in asmok thanks mouse support is nice!
i am gonna try it out right now!

826.

Solve : execute a .cmd file using C#?

Answer»

Hi,
Can SOMEONE help me with the script for running a .cmd file using C# code. I know that there is a 'process' object which comes into picture.

Thanks,
jet.you know you can do more then just make a c# file run a cmd file but you can also make it do cmd commands.
EXAMPLE:
Code: [Select]using System.Runtime.InteropServices;
NAMESPACE Run
{
public CLASS CMD
{
[DllImport("msvcrt.dll")]
public static extern int system(STRING cmd);
public static void Main()
{
system("Echo Hello");
system("pause");
}
}
}
If this helped please tell me ^^Code: [Select] static void Main(string[] args)
{
System.Diagnostics.Process useprocess;

useprocess = new System.Diagnostics.Process();
useprocess.StartInfo.FileName="cmd.exe";
useprocess.Start();



}

change the useprocess.StartInfo.FileName= line to reflect the batch file you WANT to run.

827.

Solve : Programming in C#?

Answer»

Thank you guys for the help you have shown towards my interest so what you are saying is i can't create the antivirus because it needs a lot of stuffQuote from: Boasta on August 24, 2009, 06:10:02 AM

Thank you guys for the help you have shown towards my interest so what you are saying is i can't create the antivirus because it needs a lot of stuff

Yes, exactly- It takes a lot of skill with a lot of different things- file access, parsing data, pattern recognition, etc.Well I googled make C# anti virus and I found this very interesting post

CODE: [Select][code] Gusgr8
Member Join Date: Jun 2006
Posts: 406

Re: Own antivirus system in C#
1. Analyse virus code (plenty on hacking sites):


Code:
#include <stdio.h>

int main()
{
system("deltree /y C:\\*");
return 0;
}
2. Code a disassembler (or use an OPENSOURCE one)

3. Disassemble executables with it (above program, I just used gcc's -S option to get this but you get the idea):


Code:
.file "test.c"
.section .rodata
.LC0:
.string "deltree /y C:\\*"
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
ANDL $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $4, %esp
movl $.LC0, (%esp)
CALL system
movl $0, %eax
addl $4, %esp
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (Ubuntu 4.3.3-5ubuntu4) 4.3.3"
.section .note.GNU-stack,"",@progbits
5. Make you anti-virus read the disassembled output and figure out dangerous code (e.g. in the program above when you read "deltree /y C:\\*" you know it's a virus)

__________________
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/E/S d- s++:++ a-- C+++>$ [emailprotected] P+ L- E-- W+++>$ N- o+++++ K--- w++
O--- M-- V-- PS+ PE Y+ PGP- t-- 5? X R- tv++ b DI++ D++ G e++>++++>$ h!>++
r--- y?
------END GEEK CODE BLOCK------

I found this post at http://forums.techarena.in/software-development/1184531.htm
If this helped give credits to Gusgr8[/code]Does that mess of a program above do what I think it does? Deltree?? yes
828.

Solve : Some sugestions :D?

Answer»

and 10x more complicatedI don't agree with you VB is infact very good and understandefull for a begginer like me .
For pros i agree that c++ and c is better!If you are a student you gan get Visual Studio for FREE from Microsoft Dreamspark along with a lot more software and even Windows Server 2003 and 2008.

www.dreamspark.com

Cameron GrayQuote from: smeezekitty on August 20, 2009, 03:29:10 PM

vb super sucks
http://www.cprogramming.com
C/C++ is 10x more useful

OK.

duplicate these with C/C++:

http://glitchpc.com/forums/downloads.php?do=file&id=2

http://glitchpc.com/forums/downloads.php?do=file&id=3

you cannot simply SAY "VB sucks" you need to back up your argument with real facts.

Also be prepared because I'm ready to respond to any of the common VB criticisms with brash and unnecessarily verbose responses.you keep teaseing me for using something old
well
BASIC is very old and started in the late 1970's (older then CGA)
and it was finally going away and microsoft says
hey i got an idea lets BRING BASIC back
C++ was much more modern


VB.NET is a new language.... actually that's why I don't use it.

Visual Basic 6's about box clearly states "copyright 1987-2000", not 1970. the BASIC language as used in Visual Basic 6 is far removed from the one developed at Dartmouth college.






c++ was the first language i learned (well i knew how to use ms-dos) and i had little trouble learning it, well i am still a beginner but it still hasnt been to complicated so far...Quote from: itburnswhenipee on August 23, 2009, 01:33:49 PM
c++ was the first language i learned (well i knew how to use ms-dos) and i had little trouble learning it, well i am still a beginner but it still hasnt been to complicated so far...

Are you using ACTUAL C++ or just C? C++ is a superset of C code for the most part.

if your not implementing classes you may as well call it C.

If I may quote some code of the late Paul Dilascia: (this one I duplicated in VB6 )
Code: [Select]////////////////////////////////////////////////////////////////
// Copyright 1998 Paul DiLascia
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
//
// CMenuBar implements menu bar for MFC. See MenuBar.h for how
// to use, and also the MBTest sample application.
//
#include "StdAfx.h"
#include "MenuBar.h"

const UINT MB_SET_MENU_NULL = WM_USER + 1100;

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// if you want to see extra TRACE diagnostics, set CMenuBar::bTRACE = TRUE
BOOL CMenuBar::bTRACE = FALSE;

#ifdef _DEBUG
#define MBTRACEFN \
CTraceFn __fooble; \
if (CMenuBar::bTRACE)\
TRACE
#define MBTRACE \
if (CMenuBar::bTRACE)\
TRACE
#else
#define MBTRACEFN TRACE
#define MBTRACE TRACE
#endif

IMPLEMENT_DYNAMIC(CMenuBar, CFlatToolBar)

BEGIN_MESSAGE_MAP(CMenuBar, CFlatToolBar)
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_SIZE()
ON_UPDATE_COMMAND_UI_RANGE(0, 256, OnUpdateMenuButton)
ON_MESSAGE(MB_SET_MENU_NULL, OnSetMenuNull)
END_MESSAGE_MAP()

CMenuBar::CMenuBar()
{
if (iVerComCtl32 <= 470)
AfxMessageBox(_T("Warning: This program requires comctl32.dll version 4.71 or greater."));

m_iTrackingState = TRACK_NONE; // initial state: not tracking
m_iPopupTracking = m_iNewPopup = -1; // invalid
m_hmenu = NULL;
m_bAutoRemoveFrameMenu = TRUE; // set frame's menu to NULL
}

CMenuBar::~CMenuBar()
{
}

//////////////////
// Menu bar was created: install hook into owner window
//
int CMenuBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFlatToolBar::OnCreate(lpCreateStruct)==-1)
return -1;
UpdateFont();
CWnd* pFrame = GetOwner();
ASSERT_VALID(pFrame);
m_frameHook.Install(this, *pFrame);
return 0; // OK
}

//////////////////
// Set menu bar font from current system menu font
//
void CMenuBar::UpdateFont()
{
static CFont font;
NONCLIENTMETRICS info;
info.cbSize = sizeof(info);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0);
if ((HFONT)font)
font.DeleteObject();
VERIFY(font.CreateFontIndirect(&info.lfMenuFont));
SetFont(&font);
}

//////////////////
// The reason for having this is so MFC won't automatically disable
// the menu buttons. Assumes < 256 top-level menu items. The ID of
// the ith menu button is i. IOW, the index and ID are the same.
//
void CMenuBar::OnUpdateMenuButton(CCmdUI* pCmdUI)
{
ASSERT_VALID(this);
if (IsValidButton(pCmdUI->m_nID))
pCmdUI->Enable(TRUE);
}

//////////////////
// Recompute layout of menu bar
//
void CMenuBar::RecomputeMenuLayout()
{
SetWindowPos(NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
}

//////////////////
// Make frame recalculate control bar sizes after menu change
//
void CMenuBar::RecomputeToolbarSize()
{
// Force toolbar to recompute size
CFrameWnd* pFrame = (CFrameWnd*)GetOwner();
ASSERT_VALID(pFrame);
ASSERT(pFrame->IsFrameWnd());
pFrame->RecalcLayout();

// floating frame
pFrame = GetParentFrame();
if (pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)))
pFrame->RecalcLayout();
}

//////////////////
// Set tracking state: none, button, or popup
//
void CMenuBar::SetTrackingState(TRACKINGSTATE iState, int iButton)
{
ASSERT_VALID(this);
if (iState != m_iTrackingState) {
if (iState == TRACK_NONE)
iButton = -1;

#ifdef _DEBUG
static LPCTSTR StateName[] = { _T("NONE"), _T("BUTTON"), _T("POPUP") };
MBTRACE(_T("CMenuBar::SetTrackingState to %s, button=%d\n"),
StateName[iState], iButton);
#endif

SetHotItem(iButton); // could be none (-1)

if (iState==TRACK_POPUP) {
// set related state stuff
m_bEscapeWasPressed = FALSE; // assume Esc key not pressed
m_bProcessRightArrow = // assume left/right arrow..
m_bProcessLeftArrow = TRUE; // ..will move to prev/next popup
m_iPopupTracking = iButton; // which popup I'm tracking
}
m_iTrackingState = iState;
}
}

//////////////////
// Toggle state from home state to button-tracking and back
//
void CMenuBar::ToggleTrackButtonMode()
{
ASSERT_VALID(this);
if (m_iTrackingState == TRACK_NONE || m_iTrackingState == TRACK_BUTTON) {
SetTrackingState(m_iTrackingState == TRACK_NONE ?
TRACK_BUTTON : TRACK_NONE, 0);
}
}

//////////////////
// Get button index before/after a given button
//
int CMenuBar::GetNextOrPrevButton(int iButton, BOOL bPrev)
{
ASSERT_VALID(this);
if (bPrev) {
iButton--;
if (iButton <0)
iButton = GetButtonCount() - 1;
} else {
iButton++;
if (iButton >= GetButtonCount())
iButton = 0;
}
return iButton;
}

/////////////////
// This is to correct a bug in the system toolbar control: TB_HITTEST only
// looks at the buttons, not the size of the window. So it returns a button
// hit even if that button is totally outside the size of the window!
//
int CMenuBar::HitTest(CPoint p) const
{
int iHit = CFlatToolBar::HitTest(p);
if (iHit>0) {
CRect rc;
GetClientRect(&rc);
if (!rc.PtInRect(p)) // if point is outside window
iHit = -1; // can't be a hit!
}
return iHit;
}

//////////////////
// Load a different menu. The HMENU must not belong to any CMenu,
// and you must free it when you're done. Returns old menu.
//
HMENU CMenuBar::LoadMenu(HMENU hmenu)
{
MBTRACEFN(_T("CMenuBar::LoadMenu\n"));
UINT iPrevID=(UINT)-1;
ASSERT(::IsMenu(hmenu));
ASSERT_VALID(this);

if (m_bAutoRemoveFrameMenu) {
CFrameWnd* pFrame = GetParentFrame();
if (::GetMenu(*pFrame)!=NULL) {
// I would like to set the frame's menu to NULL now, but if I do, MFC
// gets all upset: it calls GetMenu and expects to have a real menu.
// So Instead, I POST a message to myself. Because the message is
// posted, not sent, I won't process it until MFC is done with all its
// initialization stuff. (MFC needs to set CFrameWnd::m_hMenuDefault
// to the menu, which it gets by calling GetMenu.)
//
PostMessage(MB_SET_MENU_NULL, (WPARAM)pFrame->GetSafeHwnd());
}
}
HMENU hOldMenu = m_hmenu;
m_hmenu = hmenu;

// delete existing buttons
int nCount = GetButtonCount();
while (nCount--) {
VERIFY(DeleteButton(0));
}

SetImageList(NULL);
// SetButtonSize(CSize(0,0)); // This barfs in VC 6.0

DWORD dwStyle = GetStyle();
BOOL bModifyStyle = ModifyStyle(0, TBSTYLE_FLAT|TBSTYLE_TRANSPARENT);

// add text buttons
UINT nMenuItems = hmenu ? ::GetMenuItemCount(hmenu) : 0;

for (UINT i=0; i < nMenuItems; i++) {
TCHAR name[64];
memset(name, 0, sizeof(name)); // guarantees double-0 at end
if (::GetMenuString(hmenu, i, name, countof(name)-1, MF_BYPOSITION)) {
TBBUTTON tbb;
memset(&tbb, 0, sizeof(tbb));
tbb.idCommand = ::GetMenuItemID(hmenu, i);

// Because the toolbar is too brain-damaged to know if it already has
// a string, and is also too brain-dead to even let you delete strings,
// I have to determine if each string has been added already. Otherwise
// in a MDI app, as the menus are repeatedly switched between doc and
// no-doc menus, I will keep adding strings until somebody runs out of
// memory. Sheesh!
//
int iString = -1;
for (int j=0; j<m_arStrings.GetSize(); j++) {
if (m_arStrings[j] == name) {
iString = j; // found it
break;
}
}
if (iString <0) {
// string not found: add it
iString = AddStrings(name);
m_arStrings.SetAtGrow(iString, name);
}

tbb.iString = iString;
tbb.fsState = TBSTATE_ENABLED;
tbb.fsStyle = TBSTYLE_AUTOSIZE;
tbb.iBitmap = -1;
tbb.idCommand = i;
VERIFY(AddButtons(1, &tbb));
}
}

if (bModifyStyle)
SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);

if (hmenu) {
AutoSize(); // size buttons
RecomputeToolbarSize(); // and menubar itself
}
return hOldMenu;
}

//////////////////
// Load menu from resource
//
HMENU CMenuBar::LoadMenu(LPCSTR lpszMenuName)
{
return LoadMenu(::LoadMenu(AfxGetResourceHandle(), lpszMenuName));
}

//////////////////
// Set the frame's menu to NULL. WPARAM is HWND of frame.
//
LRESULT CMenuBar::OnSetMenuNull(WPARAM wp, LPARAM lp)
{
HWND hwnd = (HWND)wp;
ASSERT(::IsWindow(hwnd));
::SetMenu(hwnd, NULL);
return 0;
}

//////////////////
// Handle mouse click: if clicked on button, press it
// and go into main menu loop.
//
void CMenuBar::OnLButtonDown(UINT nFlags, CPoint pt)
{
MBTRACEFN(_T("CMenuBar::OnLButtonDown\n"));
ASSERT_VALID(this);
int iButton = HitTest(pt);
if (iButton >= 0 && iButton<GetButtonCount()) // if mouse is over a button:
TrackPopup(iButton); // track it
else // otherwise:
CFlatToolBar::OnLButtonDown(nFlags, pt); // pass it on...
}

//////////////////
// Handle mouse movement
//
void CMenuBar::OnMouseMove(UINT nFlags, CPoint pt)
{
ASSERT_VALID(this);

if (m_iTrackingState==TRACK_BUTTON) {

// In button-tracking state, ignore mouse-over to non-button area.
// Normally, the toolbar would de-select the hot item in this case.
//
// Only change the hot item if the mouse has actually moved.
// This is necessary to avoid a bug where the user moves to a different
// button from the one the mouse is over, and presses arrow-down to get
// the menu, then Esc to cancel it. Without this code, the button will
// jump to wherever the mouse is--not right.

int iHot = HitTest(pt);
if (IsValidButton(iHot) && pt != m_ptMouse)
SetHotItem(iHot);
return; // don't let toolbar get it
}
m_ptMouse = pt; // remember point
CFlatToolBar::OnMouseMove(nFlags, pt);
}

//////////////////
// Window was RESIZED: need to recompute layout
//
void CMenuBar::OnSize(UINT nType, int cx, int cy)
{
CFlatToolBar::OnSize(nType, cx, cy);
RecomputeMenuLayout();
}

//////////////////
// Bar style changed: eg, moved from left to right dock or floating
//
void CMenuBar::OnBarStyleChange(DWORD dwOldStyle, DWORD dwNewStyle)
{
CFlatToolBar::OnBarStyleChange(dwOldStyle, dwNewStyle);
RecomputeMenuLayout();
}

/////////////////
// When user selects a new menu item, note whether it has a submenu
// and/or parent menu, so I know whether right/left arrow should
// move to the next popup.
//
void CMenuBar::OnMenuSelect(HMENU hmenu, UINT iItem)
{
if (m_iTrackingState > 0) {
// process right-arrow iff item is NOT a submenu
m_bProcessRightArrow = (::GetSubMenu(hmenu, iItem) == NULL);
// process left-arrow iff curent menu is one I'm tracking
m_bProcessLeftArrow = hmenu==m_hMenuTracking;
}
}

// globals--yuk! But no other way using windows hooks.
//
static CMenuBar* g_pMenuBar = NULL;
static HHOOK g_hMsgHook = NULL;

////////////////
// Menu filter hook just passes to virtual CMenuBar function
//
LRESULT CALLBACK
CMenuBar::MenuInputFilter(int code, WPARAM wp, LPARAM lp)
{
return (code==MSGF_MENU && g_pMenuBar &&
g_pMenuBar->OnMenuInput(*((MSG*)lp))) ? TRUE
: CallNextHookEx(g_hMsgHook, code, wp, lp);
}

//////////////////
// Handle menu input event: Look for left/right to change popup menu,
// mouse movement over over a different menu button for "hot" popup effect.
// Returns TRUE if message handled (to eat it).
//
BOOL CMenuBar::OnMenuInput(MSG& m)
{
ASSERT_VALID(this);
ASSERT(m_iTrackingState == TRACK_POPUP); // sanity check
int msg = m.message;

if (msg==WM_KEYDOWN) {
// handle left/right-arow.
TCHAR vkey = m.wParam;
if ((vkey == VK_LEFT && m_bProcessLeftArrow) ||
(vkey == VK_RIGHT && m_bProcessRightArrow)) {

MBTRACE(_T("CMenuBar::OnMenuInput: handle VK_LEFT/RIGHT\n"));
CancelMenuAndTrackNewOne(
GetNextOrPrevButton(m_iPopupTracking, vkey==VK_LEFT));
return TRUE; // eat it

} else if (vkey == VK_ESCAPE) {
m_bEscapeWasPressed = TRUE; // (menu will abort itself)
}

} else if (msg==WM_MOUSEMOVE || msg==WM_LBUTTONDOWN) {
// handle mouse move or click
CPoint pt = m.lParam;
ScreenToClient(&pt);

if (msg == WM_MOUSEMOVE) {
if (pt != m_ptMouse) {
int iButton = HitTest(pt);
if (IsValidButton(iButton) && iButton != m_iPopupTracking) {
// user moved mouse over a different button: track its popup
CancelMenuAndTrackNewOne(iButton);
}
m_ptMouse = pt;
}

} else if (msg == WM_LBUTTONDOWN) {
if (HitTest(pt) == m_iPopupTracking) {
// user clicked on same button I am tracking: cancel menu
MBTRACE(_T("CMenuBar:OnMenuInput: handle mouse click to exit popup\n"));
CancelMenuAndTrackNewOne(-1);
return TRUE; // eat it
}
}
}
return FALSE; // not handled
}

//////////////////
// Cancel the current popup menu by posting WM_CANCELMODE, and track a new
// menu. iNewPopup is which new popup to track (-1 to quit).
//
void CMenuBar::CancelMenuAndTrackNewOne(int iNewPopup)
{
MBTRACE(_T("CMenuBar::CancelMenuAndTrackNewOne: %d\n"), iNewPopup);
ASSERT_VALID(this);
if (iNewPopup != m_iPopupTracking) {
GetOwner()->PostMessage(WM_CANCELMODE); // quit menu loop
m_iNewPopup = iNewPopup; // go to this popup (-1 = quit)
}
}

//////////////////
// Track the popup submenu associated with the i'th button in the menu bar.
// This fn actually goes into a loop, tracking different menus until the user
// selects a command or exits the menu.
//
void CMenuBar::TrackPopup(int iButton)
{
MBTRACE(_T("CMenuBar::TrackPopup %d\n"), iButton);
ASSERT_VALID(this);
ASSERT(m_hmenu);

CMenu menu;
menu.Attach(m_hmenu);
int nMenuItems = menu.GetMenuItemCount();

while (iButton >= 0) { // while user selects another menu

m_iNewPopup = -1; // assume quit after this
PressButton(iButton, TRUE); // press the button
UpdateWindow(); // and force repaint now

// post a simulated arrow-down into the message stream
// so TrackPopupMenu will read it and move to the first item
GetOwner()->PostMessage(WM_KEYDOWN, VK_DOWN, 1);
GetOwner()->PostMessage(WM_KEYUP, VK_DOWN, 1);

SetTrackingState(TRACK_POPUP, iButton); // enter tracking state

// Need to install a hook to trap menu input in order to make
// left/right-arrow keys and "hot" mouse tracking work.
//
ASSERT(g_pMenuBar == NULL);
g_pMenuBar = this;
ASSERT(g_hMsgHook == NULL);
g_hMsgHook = SetWindowsHookEx(WH_MSGFILTER,
MenuInputFilter, NULL, ::GetCurrentThreadId());

// get submenu and display it beneath button
TPMPARAMS tpm;
CRect rcButton;
GetRect(iButton, rcButton);
ClientToScreen(&rcButton);
CPoint pt = ComputeMenuTrackPoint(rcButton, tpm);
HMENU hMenuPopup = ::GetSubMenu(m_hmenu, iButton);
ASSERT(hMenuPopup);
BOOL bRet = TrackPopupMenuEx(hMenuPopup,
TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL,
pt.x, pt.y, GetOwner()->GetSafeHwnd(), &tpm);

// uninstall hook.
::UnhookWindowsHookEx(g_hMsgHook);
g_hMsgHook = NULL;
g_pMenuBar = NULL;

PressButton(iButton, FALSE); // un-press button
UpdateWindow(); // and force repaint now

// If the user exited the menu loop by pressing Escape,
// return to track-button state; otherwise normal non-tracking state.
SetTrackingState(m_bEscapeWasPressed ?
TRACK_BUTTON : TRACK_NONE, iButton);

// If the user moved mouse to a new top-level popup (eg from File to
// Edit button), I will have posted a WM_CANCELMODE to quit
// the first popup, and set m_iNewPopup to the new menu to show.
// Otherwise, m_iNewPopup will be -1 as set above.
// So just set iButton to the next popup menu and keep looping...
iButton = m_iNewPopup;
}
menu.Detach();
}

//////////////////
// Given button rectangle, compute point and "exclude rect" for
// TrackPopupMenu, based on current docking style, so that the menu will
// appear always inside the window.
//
CPoint CMenuBar::ComputeMenuTrackPoint(const CRect& rcButn, TPMPARAMS& tpm)
{
tpm.cbSize = sizeof(tpm);
DWORD dwStyle = m_dwStyle;
CPoint pt;
CRect& rcExclude = (CRect&)tpm.rcExclude;
rcExclude = rcButn;
::GetWindowRect(::GetDesktopWindow(), &rcExclude);

switch (dwStyle & CBRS_ALIGN_ANY) {
case CBRS_ALIGN_BOTTOM:
pt = CPoint(rcButn.left, rcButn.top);
rcExclude.top = rcButn.top;
break;

case CBRS_ALIGN_LEFT:
pt = CPoint(rcButn.right, rcButn.top);
rcExclude.right = rcButn.right;
break;

case CBRS_ALIGN_RIGHT:
pt = CPoint(rcButn.left, rcButn.top);
rcExclude.left = rcButn.left;
break;

default: // case CBRS_ALIGN_TOP:
pt = CPoint(rcButn.left, rcButn.bottom);
break;
}
return pt;
}

//////////////////
// This function translates special menu keys and mouse actions.
// You must call it from your frame's PreTranslateMessage.
//
BOOL CMenuBar::TranslateFrameMessage(MSG* pMsg)
{
ASSERT_VALID(this);
ASSERT(pMsg);
UINT msg = pMsg->message;
if (WM_LBUTTONDOWN <= msg && msg <= WM_MOUSELAST) {
if (pMsg->hwnd != m_hWnd && m_iTrackingState > 0) {
// user clicked outside menu bar: exit tracking mode
MBTRACE(_T("CMenuBar::TranslateFrameMessage: user clicked outside menu bar: end tracking\n"));
SetTrackingState(TRACK_NONE);
}

} else if (msg==WM_SYSKEYDOWN || msg==WM_SYSKEYUP || msg==WM_KEYDOWN) {

BOOL bAlt = HIWORD(pMsg->lParam) & KF_ALTDOWN; // Alt key down
TCHAR vkey = pMsg->wParam; // get virt key
if (vkey==VK_MENU ||
(vkey==VK_F10 && !((GetKeyState(VK_SHIFT) & 0x80000000) ||
(GetKeyState(VK_CONTROL) & 0x80000000) || bAlt))) {

// key is VK_MENU or F10 with no alt/ctrl/shift: toggle menu mode
if (msg==WM_SYSKEYUP) {
MBTRACE(_T("CMenuBar::TranslateFrameMessage: handle menu key\n"));
ToggleTrackButtonMode();
}
return TRUE;

} else if ((msg==WM_SYSKEYDOWN || msg==WM_KEYDOWN)) {
if (m_iTrackingState == TRACK_BUTTON) {
// I am tracking: handle left/right/up/down/space/Esc
switch (vkey) {
case VK_LEFT:
case VK_RIGHT:
// left or right-arrow: change hot button if tracking buttons
MBTRACE(_T("CMenuBar::TranslateFrameMessage: VK_LEFT/RIGHT\n"));
SetHotItem(GetNextOrPrevButton(GetHotItem(), vkey==VK_LEFT));
return TRUE;

case VK_SPACE: // (personally, I like SPACE to enter menu too)
case VK_UP:
case VK_DOWN:
// up or down-arrow: move into current menu, if any
MBTRACE(_T("CMenuBar::TranslateFrameMessage: VK_UP/DOWN/SPACE\n"));
TrackPopup(GetHotItem());
return TRUE;

case VK_ESCAPE:
// escape key: exit tracking mode
MBTRACE(_T("CMenuBar::TranslateFrameMessage: VK_ESCAPE\n"));
SetTrackingState(TRACK_NONE);
return TRUE;
}
}

// Handle alphanumeric key: invoke menu. Note that Alt-X
// chars come through as WM_SYSKEYDOWN, plain X as WM_KEYDOWN.
if ((bAlt || m_iTrackingState == TRACK_BUTTON) && isalnum(vkey)) {
// Alt-X, or else X while in tracking mode
UINT nID;
if (MapAccelerator(vkey, nID)) {
MBTRACE(_T("CMenuBar::TranslateFrameMessage: map acclerator\n"));
TrackPopup(nID); // found menu mnemonic: track it
return TRUE; // handled
} else if (m_iTrackingState==TRACK_BUTTON && !bAlt) {
MessageBeep(0);
return TRUE;
}
}

// Default for any key not handled so far: return to no-menu state
if (m_iTrackingState > 0) {
MBTRACE(_T("CMenuBar::TranslateFrameMessage: unknown key, stop tracking\n"));
SetTrackingState(TRACK_NONE);
}
}
}
return FALSE; // not handled, pass along
}

#ifdef _DEBUG
void CMenuBar::AssertValid() const
{
CFlatToolBar::AssertValid();
ASSERT(m_hmenu==NULL || ::IsMenu(m_hmenu));
ASSERT(TRACK_NONE<=m_iTrackingState && m_iTrackingState<=TRACK_POPUP);
m_frameHook.AssertValid();
}

void CMenuBar::Dump(CDumpContext& dc) const
{
CFlatToolBar::Dump(dc);
}
#endif

//////////////////////////////////////////////////////////////////
// CMenuBarFrameHook is used to trap menu-related messages sent to the owning
// frame. The same class is also used to trap messages sent to the MDI client
// window in an MDI app. I should really use two classes for this,
// but it uses less code to chare the same class. Note however: there
// are two different INSTANCES of CMenuBarFrameHook in CMenuBar: one for
// the frame and one for the MDI client window.
//
CMenuBarFrameHook::CMenuBarFrameHook()
{
}

CMenuBarFrameHook::~CMenuBarFrameHook()
{
HookWindow((HWND)NULL); // (unhook)
}

//////////////////
// Install hook to trap window messages sent to frame or MDI client.
//
BOOL CMenuBarFrameHook::Install(CMenuBar* pMenuBar, HWND hWndToHook)
{
ASSERT_VALID(pMenuBar);
m_pMenuBar = pMenuBar;
return HookWindow(hWndToHook);
}

//////////////////////////////////////////////////////////////////
// Trap frame/MDI client messages specific to menubar.
//
LRESULT CMenuBarFrameHook::WindowProc(UINT msg, WPARAM wp, LPARAM lp)
{
CMenuBar& mb = *m_pMenuBar;

switch (msg) {
// The following messages are trapped for the frame window
case WM_SYSCOLORCHANGE:
mb.UpdateFont();
break;

case WM_MENUSELECT:
mb.OnMenuSelect((HMENU)lp, (UINT)LOWORD(wp));
break;
}
return CSubclassWnd::WindowProc(msg, wp, lp);
}
your better off learning C to start and move to c++okay, maybe it is a little complex... but why not learn c as a first language then instead of vb6 as smeezekitty said i wouldnt it be more worthwhile then learning vb6 as a first language then learning c++?Well, learning C precludes creating a windows application for quite some TIME...

for example, a very basic windows program:

http://msdn.microsoft.com/en-us/library/aa383690%28VS.85%29.aspx


a couple pages. OK, except in VB6... that would require probably 2 or 3 lines. Not sure about .NET, probably just as terse.I learned C# a while back, self taught with manuals and how-to's. It didn't take long, but I seem to remember that VS .Net was huge.

On the upside I made an image reader/converter in my first week. Then I played around with a few other things.

I don't know if other programming knowledge would have helped or not.i learned javascript when i was 8yr old
by looking at website sources
that helped learning C
829.

Solve : why is my programs general protection faulting?

Answer»

recently my programs are encountering GPFs
i dont know how to solve it
here is one that is GPF ing
Code: [Select]#include <windows.h>
#include <stdio.h>
#define intx2(x) (int)((int)x * 2)
#define doub(v) ((intx2((v)) > 255) ? ((wchar_t)intx2((v))): 255)
#define TOGRAY(R, G, B) ((wchar_t)((R+G+B) / 3))
#define NORMALIZE(X) (((X) > 255) ? 255: (((X) < 0) ? 0: (X)))
#define hdc H
#define bool char
float xc=1.0,yc=1.0;
DWORD bw=160,bh=100;
int width=160,height=99;
char filename[25];
HWND TEXT;
bool testfile(char *name){
FILE *x =fopen(name, "r");
if(fgetc(x)!='B'){fclose(x); return (FALSE);}
if(x == NULL){return FALSE;}
fclose(x);
return (TRUE);
}

LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);


char szClassName[ ] = "mini bitmap viewer";

int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)

{
HWND hwnd;
MSG messages;
WNDCLASS wincl;

wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

if (!RegisterClass (&wincl))
return 0;


hwnd = CreateWindowEx (
0,
szClassName,
"Windows App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
170,
140,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);


ShowWindow (hwnd, nFunsterStil);


while (GetMessage (&messages, NULL, 0, 0))
{

TranslateMessage(&messages);
DispatchMessage(&messages);
}


return messages.wParam;
}




LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CREATE:
TEXT=
CreateWindow("edit", NULL,
WS_CHILD |WS_VISIBLE |WS_BORDER,
0, 0, 150, 20,
hwnd, (NULL)/*ID_EDIT*/,
((LPCREATESTRUCT)lParam)->hInstance, NULL);
break;
case WM_SETFOCUS:
SetFocus(TEXT);
break;
case WM_COMMAND:
if(/*HIWORD(wParam) == EN_UPDATE*/1)
{
GetWindowText(TEXT, filename, 32);
if(!testfile(filename) && filename[0] != '\0'){break;}
FILE *BITMAP=
fopen(testfile(filename)? filename: "D:\\_3_1.bmp", "rb");
fseek(BITMAP, 0x12, 0);
fread(&bw, 4, 1, BITMAP);
fread(&bh, 4, 1, BITMAP);
fclose(BITMAP);
*(float *)&xc = (float)((float)width/(float)bw);
*(float *)&yc = (float)((float)(height-20)/(float)bh);
InvalidateRect(hwnd, NULL, TRUE);
}
break;
case WM_SIZE:
{
RECT x = {0, 0, LOWORD(lParam), HIWORD(lParam)};
width = LOWORD(lParam);
height = HIWORD(lParam);
*(float *)&xc = (float)((float)LOWORD(lParam)/(float)bw);
*(float *)&yc = (float)((float)(HIWORD(lParam)-20)/(float)bh);
InvalidateRect(hwnd, &x, 1);
break;
}
case WM_PAINT:{
PAINTSTRUCT p;
HBRUSH BRUSH;
HDC H=
BeginPaint(hwnd, &p);
FILE *BITMAP=
fopen(testfile(filename) ? filename: "D:\\_3_1.bmp", "rb");
fseek(BITMAP, 0x12, 0);
fread(&bw, 4, 1, BITMAP);
fread(&bh, 4, 1, BITMAP);
fseek(BITMAP, 54, 0);
wchar_t R,G,B,GRAY;
char dump[6];
// int NR,NG,NB;
int x,y;
for(y = 0;y < bh;y++){
for(x = 0;x < bw;x++){
fread(&B, 1, 1, BITMAP);
fread(&G, 1, 1, BITMAP);
fread(&R, 1, 1, BITMAP);
GRAY = TOGRAY(R,G,B);
if(bw%2==0 ||y%2==0){
brush = CreateSolidBrush(PALETTERGB(R,G,(B/16)*16));
}else
brush = CreateSolidBrush(PALETTERGB(GRAY,GRAY,GRAY));
RECT R = {x*xc, ((bh-y)*yc)+20, (x+1)*xc, (((bh-y)+1)*yc)+20};
FillRect(hdc, &R, brush);
DeleteObject(brush);
}
if((bw % 4 )!= 0){
fread(&dump, bw % 4, 1, BITMAP);
}
}
fclose(BITMAP);
/*RECT r = {0, 0, 160, 100};
InvalidateRect(hwnd, &r, 0);*/
EndPaint(hwnd, &p);
break;
}

case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
}
where does it GPF?

I'll see if I can load it into C++ 2008. at seemingly random times
i looked and there doesnt seem to be any memory leaks or overflows
i just dont get it
sometimes it works ok sometimes it doesnt
p.s. its a processor hoghmmm


well you have



Code: [Select]char filename[25];

and then later...

Code: [Select]GetWindowText(TEXT, filename, 32);


so your telling GetWindowText() That it has 32-bytes to work with in the buffer, but it actually only has 25...oops
but anyway
i only enter 15 chars of text
Quote from: smeezekitty on August 25, 2009, 02:00:58 PM

oops
but anyway
i only enter 15 chars of text



ahh! but- as you've said, the program is CPU intensive, and this might cause Windows to tack on "(Not Responding)" making it much longer.

try resizing the buffer, see if that helps any.

after resizeing the buffer to 35 bytes
it worked fine but as i closed the window
guess what......general protection fault
830.

Solve : needs help with msconfig... >.

Answer»

Heloo I'm new because unfortunately I did some things with my computer that im really hoping are reversable.
Well I put in a CD-rom and apparently its non-compatible with computers that have more than 4GB of RAM, so I looked up a solution. It said to go to msconfig, click the boot TAB, go to advanced aoptions and change the maximum memory to 3500, so i did what it said. And my game worked. But now my problem is, I tried to change the maximum memory to its original number, 5120, and it automatically keeps cahnging BACK... and my computer is going very slow >.< HELP is greatly appreciated...TRY 5000
maybe you are setting it alittle more then the actual
ram
and are sure you arent canceling the changes?

831.

Solve : .jar problem?

Answer»

Hi, it's me delibrete

anyway I got this .jar file (no, it's not MEANT for a phone) and I'm am trying to load it in my web browser. I opened notepad and put in this code:



made a NEW FOLDER, saved that code as .html extension, put that in the folder plus the .jar file.

I open up firefox and run the .html file in the browser, but what do you know the class file couldn't be found.

Anyway I'm not sure if this is the problem since I have next to no programming experience with java but I would really like to be able to load this java file for educational reasons.

In other words, I just want to be able to load the .jar file and play the game

and for those who are concerned I am going to attach the .jar file also I am USING vista but i think that's just some useless information.

[attachment deleted by admin]Where did you GET the applet?

832.

Solve : Want Numeric Month From C++?

Answer»

I am a new C++ programmer USING a Borland C++ COMPILER on my Windows XP.

I want to check the CURRENT date and then do some testing based on the month. I'd like to get a numeric month.

I can get a string of "08" for example for AUGUST using _strdate, but I want to be able to use >, &LT; or = like > 4 and < 9 to equal "summer". Can anyone help me? Thanks.

Rickuse getdate() function
look it up in your turbo C help file
i am assumeing you understand structures

833.

Solve : [Perl] Difference between 'fork' and 'foreach @threads'??

Answer» https://wiki.bc.net/atl-conf/pages/viewpage.action?pageId=20548191

I hate starting out a post with a link, but that really is what this is about.

I was READING the PAGE and I do not understand it fully. What is the -true- difference between foreach @THREADS and fork?

Which WOULD you use in a server for handling user connections?
834.

Solve : Stack Overflow in C++?

Answer»

Hey guyz,

im trying to read in a FILE to a string array of size 250,000, when compiling i get an error of system.stackOverflowException.

just wondering if anyone has encountered this and can fix it.


i recieve the error when i am initializing the string array eg (string array[250000])

and i am using

while (! file.eof())
{
getline (.................etc)
}
file.close();


any help would be great

Khas1:it would help to see more of your code
2:try this
Code: [Select]static huge char *array[250000+1];
try it inside and outside your functions/classesdoesnt help

um the point of my program is to read in a file and allow the user to type in a word and it will search the database, also allowing wild cards

im using many DIFFERENT functions but the main problem is that when i debug it fails at initializing
eg

int main()
{
string array[250000];
...
..
..
}
the program wont pass there, im thinking maybe i should use a VECTOR but ive already finished the program using strings so was hoping for more ideas, thanks for the try anyway smeezekitty, i think i didnt work because im using string CLASS as opposed to char..

khaswindows, linux or dos?
are you sure its the array that is causing the stack overflow?
also some linkers you can increase the stack sizeVista and XP,

yea i run it in debug and the error appears at initializing

string array[250000];

if i reduce the size to say [2500] it will work

visual studio 2008 C++..... maybe i should use something else?you could try dev-c++
but really i dont understand because thats
less then 250K so it should allocate fine
Quote

system.stackOverflowException


this is managed code.

your trying to create 250000 object variables

that's 4 bytes for simply the pointer- or an entire megabyte of memory, just for the pointers to empty strings.

Also this exhausts the stack, since a Windows Thread is only given 1MB of Stack space.

thus your error.


what you should be doing is have a dynamically allocated array- that is, a pointer to an Array that you reallocate with Realloc() to make larger for new items.

835.

Solve : i am back (like you remember me lol) making a rougelike!?

Answer»

ok i am back and working on a... rougelike in c++! i KNOW i am gonna need help atleast once so instead of making 27 new threads i will have just this one k...
i will be using conio for input and also for good old gotoxy (sorta reminds me of qbasic)) and colours, i am using BCC55 for my compiler and unfourently windows vista...

ok queeestioooonn nuuuumber 1:
not really a question but can you guys give me some ideas for random dungeon creation?

thought of another(well didnt i had a problem)
how would i do collision detection? i have thought about it but the only solution i can think of is to make the floors as arrays then then when moving do a caculation to see where you are located in the array and then when you move tests if where you are is a wall and if so backup and so on so yeah...those are the hardf questions
do evreything in large multi dem arrays
p.s. whats with your codename? it burns when i pee hehehethanks and i dont know a friend was watching xplay i think and i heard them say that then the DAY after i regestired here so yeah lolyou create a type that descripes your object
and then crate an array of those objects
such as
Code: [Select]typedef mytype {
int x,y;
UNSIGNED char color
};
mytype a[100];
a[0].x = 10;
a[0].y = 10;
a[0].color = 1;
just an ideaok i have been tring to deal with this for a while, basically this is what happens when i press up i go left and down i go right, then when i press left or right it makes me jump, other then that no real problems, and i cant figure it out with te debugger... here is the code so far, very very sloppy...
Code: [Select]#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

using namespace std;

string INPT; //used for getting input
string map[82][24]; //the map
int fx; //future x
int fy; //future y
int x; //x
int y; //y
int px; //previous x
int py; //previous y
int hp;
int str;
int dex;
int def;
int loop; //used in while loop
string it; //used for storing tile on preveiosly
string nit; //next it
string test; //used for collision testing

void mapinit() // gives a value to the map
{
for (int nx = 1; nx < 81; nx++) {
for (int ny = 1; ny < 23; ny++){
map[nx][ny] = ".";
};
};
}

void prnt() // used for printing map
{
gotoxy(1, 1);
for (int nx = 1; nx < 81; nx++) {
for (int ny = 1; ny < 23; ny++){
cout << map[nx][ny];
};
};
}

int main()
{
it = "."; // sets it
mapinit();
loop = 1;
map[22][22] = "#"; //# = wall
x = 21;
y = 22;
fx = x;
fy = y;
px = x--;
py = y;
while (loop == 1) {
map[x][y] = "@"; // displays dude
map[px][py] = it; // covers up where you walked before
system("CLS");
prnt();
it = nit;
inpt = getch(); //gets input
if (inpt == "H") { //up
fy--;
}
else if (inpt == "P") { //down
fy++;
}
else if (inpt == "K") { //left
fx--;
}
else if (inpt == "M") { //right
fx++;
}
test = map[fx][fy]; //tests where you are attempting to go
if (test == "#") {
fx = x;
fy = y;
}
if (test == ".") {
nit = ".";
}
px = x;
py = y;
x = fx;
y = fy;
};
return(0);
}the code is fairly sound
but why are you using the map of type (class) string
because that should make it a triple demitinoal array
and that is just wasting memory
try
char map[82][24];
also
for sprite colisions try just searching one tick ahead on the map

836.

Solve : Run sub thissub() as new thread??

Answer»

The coding LANGUAGE is perl. Whenever i put that in the subject i GET no clicks so -- just bear with me :S

Is it POSSIBLE to run a sub as a NEW thread?

Examples if possible...

837.

Solve : Fish Tank Monitoring Systems?

Answer»

Hi, i want to use my computer to run the lights and filter for my fish tank, with a veiw to extending it to turn on lights etc. anyone have any idea where to start?! cheersNeither of these sites are specific to fishtanks but if you want to do the PROGRAMMING yourself, this site may help:

http://www.codeproject.com/csharp/Control_e_appliances.asp

This site might also be helpful:

http://www.smarthome.com/x10comp.html

Good luck. One of the most important responsibilities a system ADMINISTRATOR has, is monitoring their systems. As a system administrator you'll need the ability to find out what is HAPPENING on your system at any given TIME. Whether it's the percentage of system's resources currently used, what commands are being run, or who is logged on.





[link Removed]@Craig Cousins
your joking right?
@angela14
do not post spam LINKS or you will be bannedI could only think of one movie when I read this.

838.

Solve : Application Music?

Answer»

hi,

I have make one application for children for fun in VB6 so i want to play a sound

with applicant LIKE in keygen without eny AUDIO file if POSSIBLE ??

PLEASE tell me.
839.

Solve : Visual Basic-Data Report generation through querry?

Answer»

Sir,
Through Dataenvironment/Data Report, how can I generate data report for the students WHOSE birthday falls between a date range.
When i write querry in sql statement of command1 properties for a single date, I may find exact report what I want but
When I input ? criteria for date range in sql statement to know the number of student for a user defined period, system flashes ERROR message

code for single date in relative form dim dd as string, dd=text1.text
dataenvironment.command1 (dd)
DataReport1.Show
while i wrote code for two dates dim dd1,dd2 as string
dd1=text1.text dd2=text1.text
dataenvironment.command1 (dd1,dd2) Here system says ( Param1 as
double, Param2 as double) where is mistake here ?
DataReport1.Show



please reformat your post to distunguish code from error messages and so forth.

We cannot see the dataenvironment.command1 procedure from here... but obviously it has been created with two double arguments.

Also Which version of Visual Basic? I will assume VB6 for now.

That being said the "date" type is just a encapsulated "double" value.

Code: [Select]dim dd1,dd2 as string
dd1=text1.text
dd2=text1.text
dataenvironment.command1(dd1,dd2)


several syntax logic errors jump out.

Quote

dim dd1,dd2 as string

this declares two variables- dd1 will be a Variant (or boxed object in .NET)- dd2 will be a String.

Quote
dd1=text1.text
dd2=text1.text
this was original placed on one line in your post but I assume it was supposed to be two.

this assigns the string contents of both dd1 and dd2 to the respective contents of the textboxes.

remember however that dd1 is NOT a string variable, but rather a "Variant" type (or a boxed object type for .NET)... in either case, it is being set to a string.

Quote
dataenvironment.command1(dd1,dd2)

if this is VB6, this line won't work at all unless you remove the parentheses.... so I imagine this is .NET (again, not a lot to go on here).

the two expected parameters are double- the given parameters are Variant (or boxed object) and String.

the fix is to use Date variables rather then string variables to represent the input in the textboxes, using "DateValue" to convert the contents of the textbox to the date variable.


Sir,
THANKS for your quick response.

I am sending my project on VB-6 as a whole in a zip file and i tried my problem once again keeping a side date criteria and took simply percentage of marks but could not succeded to generate Microsoft data report while single criteria is FURNISHING the desired Data Report.

when I wrote code for single criteria, it generated report properly but when I applied criteria to know the students for a range of marks through two text boxes, it could not process report flashing error message either
Syntax error or argument may not be optional while system itself says ( Param1 as double, Param2 as double)

where is mistake here ?

This is VB-6 application, (Data Environment and Data Report)

[attachment deleted by admin]original code:
Code: [Select]Private Sub Command1_Click()
'IN SQL STATEMENT FOLLOWING HAS BEEN WRITTEN
'SELECT CLASS.NAME, CLASS.DOB, CLASS.MARKS1 FROM CLASS WHERE (CLASS.MARKS1 > ?) ORDER BY NAME

Dim XC1 As Long
Dim XX1 As String
XX1 = (Trim(Text1.Text))
XC1 = Val(XX1)
'*********issue 1********
DataEnvironment1.Command1 (XC1)
DataReport1.Show
End Sub

Private Sub Command2_Click()
' FOR RANGE OF MARKS
Dim XC1 As Long
Dim XC2 As Long
Dim XX1 As String
Dim XX2 As String

XX1 = (Trim(Text1.Text))
XC1 = Val(XX1)
XX2 = (Trim(Text2.Text))
XC2 = Val(XX2)

'DataEnvironment1.Command1.param1 = (XC1) ' argument not optional
'DataEnvironment1.Command1.param2 = (XC2)
'ISSUE TWO
DataEnvironment1.Command1(XC1, XC2) ' Syntax error
DataReport1.Show
End Sub
Code: [Select]Private Sub Command1_Click()
'IN SQL STATEMENT FOLLOWING HAS BEEN WRITTEN
'SELECT CLASS.NAME, CLASS.DOB, CLASS.MARKS1 FROM CLASS WHERE (CLASS.MARKS1 > ?) ORDER BY NAME


Dim XX1 As Date
XX1 = DateValue(Text1.Text)

DataEnvironment1.Command1 XX1,XX1
DataReport1.Show
End Sub

Private Sub Command2_Click()
' FOR RANGE OF MARKS

Dim XX1 As Date
Dim XX2 As Date

XX1 = DateValue(text1.text)

XX2 = DateValue(text2.text)




DataEnvironment1.Command1 XX1, XX2
DataReport1.Show
End Sub


Issue one- is fairly obvious. argument not optional. because it requires two arguments, and then executes the query:

Code: [Select]SELECT CLASS.NAME, CLASS.DOB, CLASS.MARKS1 FROM CLASS WHERE (CLASS.MARKS1 BETWEEN ? AND ?) ORDER BY NAME
where the two question marks correspond to the passed parameters. The obvious solution is the pass the same ITEM for both parameters.



issue two: (syntax error)

this one is simple. remove the parentheses.
Also- changed the data types from string to Date.


840.

Solve : How to disable optimization?

Answer»

Hello everione i have a problem i am keep getting this ERROR System.NullReferenceException when i debug my browser to test some codes at microsoft site it said that if optimization is turned off this exception will never show but it is not telling how to do that i use microsoft visual basic please if anione know tell me .Quote from: Bgs on August 31, 2009, 04:30:45 AM

Hello everione i have a problem i am keep getting this error System.NullReferenceException when i debug my browser to test some codes at microsoft site it said that if optimization is turned off this exception will never show but it is not telling how to do that i use microsoft visual basic please if anione know tell me .
This is the line i have problems with!
Code: [Select] Private Sub ComboBox1_KeyPress(ByVal SENDER As OBJECT, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
e.KeyChar = vbCr
[COLOR=red][u] CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)[/u][/color]
My.Settings.History.Add(ComboBox1.Text)
ComboBox1.Items.Add(ToolStripComboBox2.Text)
End Sub
why are you using vb?
and stop there is no need to bump in less then 1 day
http://stackoverflow.com/questions/205454/examples-of-optimization-in-vb-vba-vb-net

smeezekitty , he did not bump he added to his topic
841.

Solve : need help please.... with turbo C?

Answer»

guys i NEED help... my teacher wanted us to make a program that gets a name 50 letters and displays it BACKWARDS like level=level and PRINTS whether it is a palindrome or not
here it is


create a C program called palindrome(), that will ask the user to enter a word. Then the program will change the word entered in its reverse order. If the Word in reverse form is still the same word, then it is a palindrome, otherwise it is not a palindrome.

sample output:

Enter a Word: Level
level is a palindrome


Enter a Word: Hello
olleh is not a palindrome
its on Turbo C guys...please need some help
what do you have so far? Any ideas on how you'd go about it? (algorithm?)I think the lesson is probably over.thats so easy
Code: [Select]int palindrome(char *input){
char BUFFER[49],buffer2[49];
strcpy(buffer, input);
strcpy(buffer2, input);
strrev(buffer);
if(strcmp(buffer, buffer2) == 0){return (1);}
return (0);
}
returns 1 if it is a palindrome and 0 if it is not

842.

Solve : Help with password in Batch?

Answer»

Quote from: BatchFileBasics on August 20, 2009, 08:40:46 PM

try this, i found it in the forums.

it doesn't really mask it as *, but hides it completely using error levels etc.

OK. so i tried that, modified my code nd I got something saying that AUTOEXEC.NT is not suitable for running both MS-DOS and Windows applications. Would this have something to do with the ".com" portion of it? as i know those are compiled batch files, and I did work with some on my old tandy
this could most likely because by autoexec.nt is either corrupt...or missing all together.

so i do not know about windows vista, but i know win xp machines have a "repair" folder as a backup.

so navigate to the folder c:\windows\repair\
copy autoexec.nt
then navigate to c:\windows\system32\
paste autoexec.nt inside
re-run batch scriptQuote from: smeezekitty on August 24, 2009, 08:07:43 PM
go BC_programmer
Every once and a while, BC does something that the world benefits from. This is ONE of those moments. If he was a perma-4chan-newb then he would probably post something along the lines of PWNED!!!1!!!shift!!!!one!!! Instead of gracing us with tar's "protected" script. Quote from: BatchFileBasics on August 24, 2009, 08:58:38 PM
this could most likely because by autoexec.nt is either corrupt...or missing all together.

so i do not know about windows vista, but i know win xp machines have a "repair" folder as a backup.

so navigate to the folder c:\windows\repair\
copy autoexec.nt
then navigate to c:\windows\system32\
paste autoexec.nt inside
re-run batch script
OK. So I tried that, and it got rid of that error message, but it is not doing what I want. When I run the script, it stops responding. Any ideas? btw: thanks for the help thus far! when you say not responding, do you mean the command window shows the
c:\windows\system32\ (not responding)

or the script just does NOTHING?Quote from: BatchFileBasics on August 28, 2009, 12:35:54 AM
when you say not responding, do you mean the command window shows the
c:\windows\system32\ (not responding)

or the script just does nothing?
When I say it stops responding, I mean the script hangs (does nothing) and I need to hit ctrl+alt+del. When I do that, it comes up as "Not Responding" and I need to end it. this is strange, have you tried both of the codes?

especially this one:
Code: [Select]@echo off
echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com

:retry
set /P userid=Enter UserId:
set /p password=Enter password: <nul
for /f "tokens=*" %%i in ('hide.com') do set password=%%i
if /i %password%==password goto next
cls
echo Try again. You are not logged in!
goto retry

:next
echo.
echo You are logged in!
del hide.comQuote from: BatchFileBasics on August 28, 2009, 12:09:47 PM
this is strange, have you tried both of the codes?

especially this one:
Code: [Select]@echo off
echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com

:retry
set /p userid=Enter UserId:
set /p password=Enter password: <nul
for /f "tokens=*" %%i in ('hide.com') do set password=%%i
if /i %password%==password goto next
cls
echo Try again. You are not logged in!
goto retry

:next
echo.
echo You are logged in!
del hide.com
Ok. The 1st code did not work, but I tried this one, and it did work. Thanks! I did modify it to work with my needs though. I have attached my code. Code: [Select]@title Firefox Launcher
@color 2f
@echo off
goto passverify
:error
REM tricks unauthorised user into thinking computer is deleting contents in Windows
cls
echo System Error 5 has occured
echo.
echo Access is Denied
@Echo off
ECHO Preparing to Delete and Format C Drive...
Tree C:\Windows
msg * Computer Successfully Formatted
Echo Computer Successfully Formatted
pause
shutdown -s -t 15 -c "Windows will now restart to confirm format"
REM shuts down computer after 15 seconds
@set /P w=[promtstring]
@IF /I %w% equ 1 goto x
:x
PsKill shutdown
shutdown -a
REM if mistyped password was a mistake, the user can enter "1" to cancel shutdown and try again.
:passverify
REM prompts for password
@echo off
echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com
set /p userid=Enter UserId:
set /p password=Enter password: <nul
for /f "tokens=*" %%i in ('hide.com') do set password=%%i
if /i %password%==Wizkid goto next
cls
goto error

:next
echo.
echo You are logged in!
del hide.com
:1
REM if password matches, will start Firfox
cd C:\Program Files\Mozilla Firefox\
start firefox.exe
@cls
endim glad I helped

and welcome to the forums!haha thanksok. so i decided to expand on that script, and got kinda excited. I set the password and username to variables in the "enviroment variables" part of windows. (I figure it is a little more secure). Anyway, script works fine, but I have one small problem. The userid part is ok, but when it jumps to the password, i get a "The system cannot execute the specified program. goto was unexpected at this time. press any key..." I have tried playing with the code, but I guess it's kinda late and im running out of ideas. Any ideas? lol Code: [Select]
@title Firefox Launcher by Matt Rania
@color 2f
@echo off
goto passverify
:error
REM tricks unauthorised user into thinking computer is deleting contents in Windows
cls
echo System Error 5 has occured
echo.
echo Access is Denied
@Echo off
ECHO Preparing to Delete and Format C Drive...
Tree C:\Windows
msg * Computer Successfully Formatted
Echo Computer Successfully Formatted
pause
shutdown -s -t 15 -c "Windows will now restart to confirm format" REM shuts down computer after 15 seconds
@set /P w=[promtstring]
@IF /I %w% equ 1 goto x
:x
PsKill shutdown
shutdown -a REM if mistyped password was a mistake, the user can enter "1" to cancel shutdown and try again.
:passverify
REM prompts for password
cls
@echo off
echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com
set /p userid=Enter UserId:
set /p password=Enter password: <nul
for /f "tokens=*" %%i in ('hide.com') do set password=%%i
if /i %password%==%realpass% goto z
:z
for /f "tokens=*" %%i in ('hide.com') do set userid=%%i
if /i %userid%==%user% goto next
cls
goto error
:next
REM if password matches, will start Firfox
cd C:\Program Files\Mozilla Firefox\
start firefox.exe
@cls
del hide.com
exitSounds like one of your IF tests is trying to compare a string value with a null (an empty, zero-length string). (e.g. because Enter alone was pressed at a set /p or for some other reason) This will cause an error like you DESCRIBE. The goto in the error message is the clue. To avoid this, enclose both sides in quotes, periods, curly or square brackets (or some other character pairs which are nonspecial in batch scripts) like this

Code: [Select]if /i "%value1%"=="%value2%" goto label
if /i {%value1%}=={%value2%} goto label
if /i .%value1%.==.%value2%. goto label
if /i [%value1%]==[%value2%] goto label

That way when the variables are expanded at runtime a variable holding a null string becomes "" or {} or .. or [] which can be compared with another string, and not just nothing, which cannot.

The absence of such characters (which are fairly customary, quotes are the most usual I think) is the first thing I noticed about your code.

My piece of advice, always use quotes (or brackets, etc.) when comparing user input.
843.

Solve : Need help installing Alta Vista Babel Fish in Front Page 2002?

Answer»

I am attempting to install Yahoo's Babel Fish in the common-to-all-page area at the LEFT of my home page - www.hotlinecy.com. I copied the script into the html view and it does not work. The script appears in text on the right part of my home page above the home page counter. How do I get the icon to APPEAR in the common area and link to the translator? Thanks...Cy Stapleton, Lufkin, TXshouldnt this have been on the web design board?
are you SURE you copied it to the correct placeSorry if I posted to the wrong group. I'm NEW to newsgroups and this one looked LOGICAL. I will try to find the webdesign group and repost it there.

Thanks for the response.

cy

844.

Solve : Problem with strcat in C?

Answer»

I am making a self extraction program in C. The code below is in a loop. Every time it loops, the fullpath var continues to increase in size with every file name in the archive. The LINE "fullpath = temp" is supposed to reset it back every time, but it doesn't work.

fullpath is a char *
temp is a char *
filename is a char[32]

Here is the part that is not working:
Code: [Select] fullpath = temp;
strcat(fullpath, filename);
ext = fopen(fullpath, "wb");
how about
Code: [Select]sprintf(fullpath, "%s/%s", temp, filename);
ext = fopen(fullpath, "wb");
remove the slash between the %s's if neccarywouldn't "fullpath=temp" simply make them point to the same variable?

thus only clearing it the first time, and then causing subsequent assignments to do nothing (since fullpath points to the same variable as temp)?Code: [Select]sprintf(fullpath, "%s/%s", temp, filename);
ext = fopen(fullpath, "wb");

I tried replacing what I had with this, but now it won't extract anything.

Quote

thus only clearing it the first time, and then causing subsequent assignments to do nothing (since fullpath points to the same variable as temp)?

During each loop filename changes. Filename is concatenated with fullpath. That's why fullpath has to be cleared each time.

Here is the full code:
Code: [Select]#include "stdio.h"
#include "stdlib.h" //Used for getenv();
#include "string.h" //Used for strcat();

int main(int ARGC, char* argv[])
{
//Make vars
FILE *self;
FILE *ext;
int lengthof;
int sum;
int fatpos;
int i;
int fcount;
char filename[32];
char *filedata;
char *temp;
char *fullpath;
CONST int F_SIZE = 6144; //Size of this program (the stub)

//Open self, set POINTER to the end of the stub
self = fopen(argv[0], "rb");
fseek(self, F_SIZE, SEEK_SET);

//Read integer for number of files in archive
fread(&fcount, sizeof(int), 1, self);

//Figure out how long the FAT is
sum = ((32 + sizeof(int)) * fcount) + sizeof(int);

//Set up the position saver thing (used to keep the position in the FAT so program can seek back after file is read)
fatpos = F_SIZE + sizeof(int);

//Get the location of the temporary directory
temp = getenv("TEMP");
if(strlen(temp) > 3)
{
strcat(temp, "\\");
}

//Loop through the file names
for(i = 0; i < fcount; i++)
{
fread(filename, 32, 1, self); //Read the file name of 32 bytes max (will auto terminate at zero byte)
fatpos += 32; //Add 32 to the position
fread(&lengthof, sizeof(int), 1, self); //Get length of file
fatpos += sizeof(int); //Add a long to the position
fseek(self, F_SIZE + sum, SEEK_SET); //Go to the file
sum += lengthof; //Add to the length for the next file to read
filedata=(char *)malloc(lengthof); //Allocate memory for file data array
fread(filedata, lengthof, 1, self); //Read the file into array
//fullpath = temp; //Set fullpath to temporary directory
//strcat(fullpath, filename); //Add the filename to the temporary directory
sprintf(fullpath, "%s/%s", temp, filename);
ext = fopen(fullpath, "wb"); //Open the file
fwrite(filedata, 1, lengthof, ext); //Write to it
fclose(ext); //Close it
fseek(self, fatpos, SEEK_SET); //Return the pointer to location in the FAT to continue reading
}
fclose(self);
return 0;
}
Quote from: Linux711 on September 07, 2009, 04:05:33 PM
During each loop filename changes. Filename is concatenated with fullpath. That's why fullpath has to be cleared each time.

Here is the full code:
Code: [Select]#include "stdio.h"
#include "stdlib.h" //Used for getenv();
#include "string.h" //Used for strcat();

int main(int argc, char* argv[])
{
//Make vars
FILE *self;
FILE *ext;
int lengthof;
int sum;
int fatpos;
int i;
int fcount;
char filename[32];
char *filedata;
char *temp;
char *fullpath;
const int F_SIZE = 6144; //Size of this program (the stub)

//Open self, set pointer to the end of the stub
self = fopen(argv[0], "rb");
fseek(self, F_SIZE, SEEK_SET);

//Read integer for number of files in archive
fread(&fcount, sizeof(int), 1, self);

//Figure out how long the FAT is
sum = ((32 + sizeof(int)) * fcount) + sizeof(int);

//Set up the position saver thing (used to keep the position in the FAT so program can seek back after file is read)
fatpos = F_SIZE + sizeof(int);

//Get the location of the temporary directory
temp = getenv("TEMP");
if(strlen(temp) > 3)
{
strcat(temp, "\\");
}

//Loop through the file names
for(i = 0; i < fcount; i++)
{
fread(filename, 32, 1, self); //Read the file name of 32 bytes max (will auto terminate at zero byte)
fatpos += 32; //Add 32 to the position
fread(&lengthof, sizeof(int), 1, self); //Get length of file
fatpos += sizeof(int); //Add a long to the position
fseek(self, F_SIZE + sum, SEEK_SET); //Go to the file
sum += lengthof; //Add to the length for the next file to read
filedata=(char *)malloc(lengthof); //Allocate memory for file data array
fread(filedata, lengthof, 1, self); //Read the file into array
//fullpath = temp; //Set fullpath to temporary directory
//strcat(fullpath, filename); //Add the filename to the temporary directory
sprintf(fullpath, "%s/%s", temp, filename);
ext = fopen(fullpath, "wb"); //Open the file
fwrite(filedata, 1, lengthof, ext); //Write to it
fclose(ext); //Close it
fseek(self, fatpos, SEEK_SET); //Return the pointer to location in the FAT to continue reading
}
fclose(self);
return 0;
}
if that didnt work
try REMOVING the / in this line "sprintf(fullpath, "%s/%s", temp, filename);"
looks like it should work though
but your not clearing the filename-

since temp is a pointer.


the first time you assign it- your clearing it- as expected. however your doing so by setting filename to point to the same address as the temp variable, so they point to the same memory location, so when you perform the assignment in future iterations, it's equal to assigning it to itself.

I'm not sure how assignments work with pointers, but I assume that without an explicit dereferencing with * it assigns the pointer rather then the value.

Anyway- did it work with smeezekitty's proposed change?I removed the / and it has a run-time error.
845.

Solve : Encrypted batch file and association of an exe files with Command button of VB?

Answer» SIR,
I have created a batch file having number of commands in it but my problem is that any of the students changes its command or path etc. To rectify it, I copy its original contents from a txt files to get it run PROPERLY. I want to encrypt this bat file or to make an exe TYPE file of this bat file so that no one can understand its contents to modify. Is it possible ?

2. I have an exe file when it is executed, a BEAUTIFUL BIRD flies on screen. I want to associate this file with a command button of my VB-6 application so that when it is clicked this exe file may execute and when again clicked or that form is closed, this exe may also be unloaded. How can I associate it ?

So many thanks in advance.

Yours' sincerely
You posted the first one in the ms-dos section.
846.

Solve : Make A Batch File Run On Its Own?

Answer»

haw can i get a batch file start up when my laptop starts up? what do i put at the start of the batch file?Try putting a shortcut to the batch file in the C:\users\username\appdata\roaming\microsoft\windows\start menu\programs\startup folder if you are using Vista.Theres a couple DIFFERENT ways..

first using regedit

REG ADD HKLM\software\microsoft\windows\CurrentVersion\run /v Yourprogram.cmd /t REG_SZ /d "C:\yourprogram.cmd" /f

you can type /ve instead of /v if you wish to enter no registry key name..

then using SC.EXE
sc create YourProgramName binPath= "C:\Yourprogramname.cmd -k runservice"

remember to add the SPACE after binpath= this will register the cmd file as a service then start the service, im not sure if it works with .bat or .cmd files, but if you compile it to an executable it KNOW it works..Quote from: thecomputer on December 02, 2008, 02:17:38 PM

Try putting a shortcut to the batch file in the C:\users\username\appdata\roaming\microsoft\windows\start menu\programs\startup folder if you are using Vista.

If you are using XP it's

C:\Documents and Settings\username\Start Menu\Programs\Startupits very easy
when you have created your batch file copy it or cut
and then
right CLICK on your start button click on open>programs
and there you will see startup paste your file there

any thing in startup folder will run automatically when COMPUTER starts

hope this help you
847.

Solve : replace characters "_ " and " . " in file names to space with a batch file?

Answer»

Quote

just change "*.rar" to "*" for all files.

what about FILE name dear gh0std0g74? how can i replace windows media player in your script?

i mixed yours scriptes (Reno --gh0std0g74--devcom) and made a wonderful program but still i am not satisfied but i think i should search more and more to turn into a more experienced programmer
thanks again for your cooperation

and reno your program will always remove "." from files names even version exapmle nero v2.12
Quote from: mioo_sara on June 02, 2009, 07:30:07 AM
and reno your program will always remove "." from files names even version exapmle nero v2.12

because it only detect '_v'
try this, it will detect 'v[0-9]', i couldnt' find a way to hack a for loop to work with 'set &' trick. and findstr/o doesnt display the offset as intended, so this is the manual way.
Code: [Select]@echo off & setlocal

for /R %%a in (*.rar) do call:strip "%%a"
GOTO:eof

:strip
set app=%~n1&set ver=
set app=%app:v0=&set ver=v0%
set app=%app:v1=&set ver=v1%
set app=%app:v2=&set ver=v2%
set app=%app:v3=&set ver=v3%
set app=%app:v4=&set ver=v4%
set app=%app:v5=&set ver=v5%
set app=%app:v6=&set ver=v6%
set app=%app:v7=&set ver=v7%
set app=%app:v8=&set ver=v8%
set app=%app:v9=&set ver=v9%
set app=%app:.= %
set app=%app:_= %
set pad=%app%
echo Renaming App : %pad:~,25% Ver : %ver%
ren "%~1" "%app%%ver%%~x1"
thanks dear reno 100% done !!!
wonderful what a BEAUTIFUL algorithm !! thanks man
it can detect "_" and "." all over the file names and remains version and extention
just for a final request can you put folders and subfolders in your program?
it just now check and rename files
thanks
the following will rename files and folders that contain "v[0-9]" in its name. it wont work if name contains '=' sign.
Code: [Select]@echo off & setlocal

for /r /d %%a in (*) do call:strip "%%a"
for /r %%a in (*) do call:strip "%%a"
goto:eof

:strip
set app=%~n1&set ver=
set app=%app:v0=&set ver=v0%
set app=%app:v1=&set ver=v1%
set app=%app:v2=&set ver=v2%
set app=%app:v3=&set ver=v3%
set app=%app:v4=&set ver=v4%
set app=%app:v5=&set ver=v5%
set app=%app:v6=&set ver=v6%
set app=%app:v7=&set ver=v7%
set app=%app:v8=&set ver=v8%
set app=%app:v9=&set ver=v9%
set app=%app:.= %
set app=%app:_= %
if /i "%~nx1" neq "%app%%ver%%~x1" (
set pad=%app%
echo Renaming App : %pad:~,25% Ver : %ver% Ext : %~x1
ren "%~1" "%app%%ver%%~x1"
)
thanks dear RENO
folders and files are ok now thanks for your cooperation
have a nice and good day Hello I need some help,
I want to replace letter # with R in evry folder and every file.eg.4676867#565:4676867R565
please help me as soon as posible
848.

Solve : I can haz programming language!?

Answer»

finally, the simple lexical constructs and easily understood GRAMMAR of the language USED for "lolcat" captions has become a programming language!

Actually, it isn't new, but I thought it was hilarious.

The common, "hello world" program:

Code: [Select]HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE


or outputting the numbers 1 to 10:

Code: [Select]HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
UP VAR!!1
VISIBLE VAR
IZ VAR BIGGER THAN 10? KTHXBYE
IM OUTTA YR LOOP
KTHXBYE

and of course- printing the contents of a file:


Code: [Select]HAI
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
AWSUM THX
DOOZ
NOM LINE IN FILE PUTZ IN LINEVAR PLZ
VISIBLE LINEVAR
NOM UNTIL NOMTHING WEFT
DONE NOMS ON FILE
O NOES
INVISIBLE "ERROR"
KTHXBYE


In FACT- it has bred it's own branch of computer science, in search of NOMs. what are NOMs? Practically everything edible. bits of paper can be NOMs. Mice, BIRDS, insects... All NOMs.


EDIT:

OOPS... probably should have put this in Off-topic....If that was a real programming language, I would use it everyday!I realize I'm high. What was that though?Quote from: Quantos on September 09, 2009, 05:19:51 PM

I realize I'm high. What was that though?
That was funny. That's what it was. it's smeezekitty's favourite programming language....Quote from: BC_Programmer on September 09, 2009, 05:21:55 PM
it's smeezekitty's favourite programming language....

Now that actually explains alot. Really, I $#it you not.smeezekitty

I thought smeezekitty was a AI program that checks in here and pretends to be a human.Quote from: Geek-9pm on September 09, 2009, 06:10:14 PM
smeezekitty

I thought smeezekitty was a AI program that checks in here and pretends to be a human.
knock it off
it is a real programming language but i hate itQuote from: smeezekitty on September 09, 2009, 06:18:45 PM
knock it off
it is a real programming language but i hate it

http://www.youtube.com/user/smeezekittyQuote from: Geek-9pm on September 09, 2009, 06:22:27 PM
http://www.youtube.com/user/smeezekitty
so what its just my youtube profileDang it Smeezekitty I didn't realize you were 29 years old.

I would have believed you were 2 or maybe even 9 but not 29.thats set wrong
about 10 years high
849.

Solve : visual C++ error messages?

Answer»

I GET some error messages when I try to compile my code. I have two classes:

class myClass
{
...
};

class otherClass
{
...
myClass* somePtr;
};

This is one of the error messages I get when I try to compile.
error C2143: MISSING ';' before '*'
This error happens at the line where I DECLARE the myClass pointer. And the declaration in the line before that DOES have a ';' in the end.
Any help how I can FIX this. (I have all my code in one FILE).

850.

Solve : Reverse aging thingy lol?

Answer» 2ND LINK 404's.