-
#include<windows.h>
-
#include<dos.h>
-
#include<dir.h>
-
#include<fstream.h>
-
#include<stdio.h>
-
#include<process.h>
-
-
#include"resource.h" //resource header file
-
-
-
long convert(char *pass) //to convert password in to long integer
-
{
-
long total=0;
-
for(int i=0;i<strlen(pass);i++)
-
{
-
total+=pass[i];
-
}
-
total=total;
-
return(total);
-
}
-
-
-
int check(char *p) // to check if the path entered is a file or directory
-
{
-
int done;
-
struct ffblk ffblk;
-
done=findfirst(p,&ffblk,0);
-
while(!done)
-
{
-
if(ffblk.ff_attrib&&FA_DIREC) //returns 1 if its a directory
-
return(1);
-
done=findnext(&ffblk);
-
}
-
return(0);
-
}
-
-
int encode(char *path,int op,char *pass) //fuction to encode file
-
{
-
long password=0;
-
int done;
-
char ch;
-
double ctr;
-
ifstream fin;
-
ofstream fout;
-
struct ffblk ffblk;
-
switch(op)
-
{
-
case 0:ctr=0;
-
password=convert(pass);
-
fin.open(path,ios::in|ios::binary);
-
fout.open(path,ios::out|ios::ate|ios::nocreate|ios::binary);
-
if(!fin||!fout) //place where something goes wrong I think
-
return(-1);
-
while(!fin.eof())
-
{
-
fin.seekg(ctr);
-
fin.get(ch); //reading each character
-
if(fin.eof())
-
break;
-
ch=int(ch+password); //adding some value to character(encoding)
-
fout.seekp(ctr);
-
fout.put(ch);
-
ctr++;
-
}
-
fout.flush();
-
fin.close();
-
fout.close();
-
break;
-
-
case 1:chdir(path); //changing directory if the entere path is a folder
-
done=findfirst("*.*",&ffblk,0); //searching every file
-
while(!done)
-
{
-
encode(ffblk.ff_name,0,pass);
-
done=findnext(&ffblk);
-
}
-
break;
-
default:return(-1);
-
}
-
return(0);
-
}
-
-
int decode(char *path,int op,char *pass) //to decode file:similar to encode
-
{
-
long password=0;
-
int done;
-
char ch;
-
double ctr;
-
ifstream fin;
-
ofstream fout;
-
struct ffblk ffblk;
-
if(op==-1)
-
return(-1);
-
switch(op)
-
{
-
case 0:ctr=0;
-
password=convert(pass);
-
fin.open(path,ios::in|ios::binary);
-
fout.open(path,ios::out|ios::ate|ios::nocreate|ios::binary);
-
if(!fout||!fin)
-
return(-1);
-
while(!fin.eof())
-
{
-
fin.seekg(ctr);
-
fin.get(ch);
-
if(fin.eof())
-
break;
-
ch=ch-int(password);
-
fout.seekp(ctr);
-
fout.put(ch);
-
ctr++;
-
}
-
fout.flush();
-
fin.close();
-
fout.close();
-
break;
-
case 1:chdir(path);
-
done=findfirst("*.*",&ffblk,0);
-
while(!done)
-
{
-
decode(ffblk.ff_name,0,pass);
-
done=findnext(&ffblk);
-
}
-
break;
-
}
-
return(0);
-
}
-
-
-
//No problem here I think.Here's where the dialog box stuff go
-
-
BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
-
{
-
switch(msg)
-
{
-
case WM_INITDIALOG:SetDlgItemText(hwnd,IDC_TEXT_I,"");
-
SetDlgItemText(hwnd,IDC_TEXT_II,"");
-
break;
-
case WM_COMMAND :
-
switch(LOWORD(wParam))
-
{
-
case IDC_ENCODE:{
-
int len1=GetWindowTextLength(GetDlgItem(hwnd,IDC_TEXT_I));
-
int len2=GetWindowTextLength(GetDlgItem(hwnd,IDC_TEXT_II));
-
if(len1>0&&len2>0)
-
{
-
char *buf1,*buf2;
-
buf1=(char*)GlobalAlloc(GPTR,len1+1);
-
buf2=(char*)GlobalAlloc(GPTR,len2+1);
-
GetDlgItemText(hwnd,IDC_TEXT_I,buf1,len1+1);
-
GetDlgItemText(hwnd,IDC_TEXT_II,buf2,len2+1);
-
int i=check(buf1);
-
int e=encode(buf1,i,buf2);
-
if(e==0)
-
{
-
MessageBox(hwnd,"ENCODING COMPLETED","REPORT",MB_OK|MB_ICONINFORMATION);
-
SetDlgItemText(hwnd,IDC_TEXT_I,"");
-
SetDlgItemText(hwnd,IDC_TEXT_II,"");
-
}
-
else if(e==-1)
-
{
-
MessageBox(hwnd,"ERROR IN ENCODING PROCESS","REPORT",MB_OK|MB_ICONEXCLAMATION);//This shows up as error
-
-
}
-
GlobalFree((HWND)buf1);
-
GlobalFree((HWND)buf2);
-
}
-
else
-
{
-
MessageBox(hwnd,"PARAMETER(S) MISSING","WARNING",MB_OK|MB_ICONEXCLAMATION);
-
}}
-
break;
-
case IDC_DECODE:{
-
int len1=GetWindowTextLength(GetDlgItem(hwnd,IDC_TEXT_I));
-
int len2=GetWindowTextLength(GetDlgItem(hwnd,IDC_TEXT_II));
-
if(len1>0&&len2>0)
-
{
-
char *buf1,*buf2;
-
buf1=(char*)GlobalAlloc(GPTR,len1+1);
-
buf2=(char*)GlobalAlloc(GPTR,len2+1);
-
GetDlgItemText(hwnd,IDC_TEXT_I,buf1,len1+1);
-
GetDlgItemText(hwnd,IDC_TEXT_II,buf2,len2+1);
-
int i=check(buf1);
-
int e=decode(buf1,i,buf2);
-
if(e==0)
-
{
-
MessageBox(hwnd,"ENCODING COMPLETED","REPORT",MB_OK|MB_ICONINFORMATION);
-
SetDlgItemText(hwnd,IDC_TEXT_I,"");
-
SetDlgItemText(hwnd,IDC_TEXT_II,"");
-
}
-
else if(e==-1)
-
{
-
MessageBox(hwnd,"ERROR IN DECODING PROCESS","REPORT",MB_OK|MB_ICONEXCLAMATION);//This shows up as error
-
}
-
GlobalFree((HWND)buf1);
-
GlobalFree((HWND)buf2);
-
}
-
else
-
{
-
MessageBox(hwnd,"PARAMETER(S) MISSING","WARNING",MB_OK|MB_ICONEXCLAMATION);
-
}}
-
break;
-
case IDC_about:MessageBox(hwnd,"FE for WINDOWS\r\n -by- \r\nRAHUL.ES\r\nCreated:18-2-07\r\nContact:es_rahul@yahoo.co.in","ABOUT",MB_ICONINFORMATION|MB_OK);
-
break;
-
}
-
break;
-
case WM_CLOSE : EndDialog(hwnd,0);
-
break;
-
default : return FALSE;
-
}
-
return TRUE;
-
}
-
-
-
//WinMain
-
-
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
-
{
-
HICON hMyIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
-
-
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc)
-
;
-
}
-
-
The above program is a simple program using WinApi to encode and decode files.But every time I execute it,the dialog box mentioned above in the comments appear.I can't figure out how to correct the error...
Please Help.... :-)
3 2257 DeMan 1,806
Top Contributor
Looks to me like that's what it does......sorry maybe I don't understand ur question
RedSon 5,000
Recognized Expert Expert
The dialog box does appear, what is your problem exactly?
Sorry,I meant the Message Box ,not Dialog Box.The Message Box appears saying "ERROR DURING ENCODING PROCESS"
What should I do???
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Philippe C. Martin |
last post by:
I apologize in advance for launching this post but I might get enlightment
somehow (PS: I am _very_ agnostic ;-).
- 1) I do not consider my intelligence/education above average
- 2) I am very pragmatic
- 3) I usually move forward when I get the gut feeling I am correct
- 4) Most likely because of 1), I usually do not manage to fully explain 3)
when it comes true.
- 5) I have developed for many years (>18) in many different environments,...
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from software giant such as Microsoft SQL
Server, Oracle, and Sybase?
Is PostgreSQL reliable enough to be used for high-end commercial
application? Thanks
|
by: titan0111 |
last post by:
#include<iostream>
#include<iomanip>
#include<cstring>
#include<fstream>
using namespace std;
class snowfall
{
private:
int ft;
|
by: Qiangning Hong |
last post by:
I decide to seperate my data collection routine from my data analysis
and storage program to a seperate process, so I try to use the new
subprocess model in Python 2.4.
The main program spawns the subprocess and receives data from the
pipe. When some event occurs (e.g. the user clicks the 'Stop' button
on GUI), the main program will send the subprocess a command to change
its behavior or ask it to exit.
However, my code (attached...
|
by: Keith K |
last post by:
Having developed with VB since 1992, I am now VERY
interested in C#. I've written several applications with
C# and I do enjoy the language.
What C# Needs:
There are a few things that I do believe MSFT should do to
improve C#, however.
I know that in the "Whidbey" release of VS.NET currently
| |
by: Xah Lee |
last post by:
in March, i posted a essay “What is Expressiveness in a Computer
Language”, archived at:
http://xahlee.org/perl-python/what_is_expresiveness.html
I was informed then that there is a academic paper written on this
subject.
On the Expressive Power of Programming Languages, by Matthias
Felleisen, 1990.
http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
|
by: belton180 |
last post by:
CODE]../* Program function: Simulate the stack using a stack limit of 10. Display
a menu for the the following.
Create a stack
Insert an item in the stack
Pop an item from the stack
Peep/view the item at the top of the stack
Current value of top
View all items stored in the stack
Quit
*the stack accepts lowercase & uppercase characters only from A-Z
|
by: Daniel.C |
last post by:
Hello.
I just copied this code from my book with no modification :
#include <stdio.h>
/* count characters in input; 1st version */
main()
{
long nc;
nc = 0;
|
by: broli |
last post by:
#include<stdio.h>
#include<stdlib.h>
struct point
{
double x, y, z;
|
by: hirsh.dan |
last post by:
i have a functions that writes information to a file.
inside that function i have a line in which i call another function.
if this line is executed, nothing is written to the file, but if i
remark that line, it is written.
i wanna understand what's wrong and fix it, but can't find what is
wrong.
also this line is mandatory in my code.
the code attached is in the link, minimized to the needed info, a bit
different then the way it's...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |