|
Ok, if your purpose is solely encrypt/decrypt, then this code will do. Only do open the file in binary mode, read bytes from there and pass them to your enryption algorythm. If after encryption and a corresponding decryption you cannot get what you had before, than your algorythms are wrong; no matter you have used video, image or other types of files.
--
=====
Arman
|
|
|
|
|
hey thanks duude
it worked
Jesus Loves Us Just the way we are! Invite Him into your life today!
|
|
|
|
|
Hi All,
Currently I'm developing a tool, for that purpose i have to know all other processes running on the computer and achieve the handle of specified process.There are some functions in VB and but i need to write in MFC only... How can get it?
bye
kamalesh
kamalesh
|
|
|
|
|
See the APIs Process32First, Process32Next from include header <tlhelp32.h>
--
=====
Arman
|
|
|
|
|
Does EnumProcesses helpful?
|
|
|
|
|
Pls Find answer to your code....
I dont know how i can attach a file to code project message. there fore please copy from the message...
/* Header File for the Class /*
#include "stdafx.h"
#include "psapi.h"
#pragma pack(16)
#define FOUND_WJRU 0
#define WJRU_NOTFOUND 1
class CProcessMonitor
{
private:
DWORD mAvailableProcesses[1024], cbNeeded, cProcesses;
public:
UINT getTotalAvailableProcesses();
UINT getProcessTimes();
BOOL FindProcessandMemoryDetails(DWORD processID,CString Processname,PROCESS_MEMORY_COUNTERS& psmemCounters);
BOOL IsProcessMatchingNameAndID( DWORD processID, UINT index );
HANDLE GetProcessHandle(DWORD processID, CString Processname);
HANDLE GetHandleToProcess(CString Processname);
void GetJRUStatus(int&nStatus, PROCESS_MEMORY_COUNTERS& psMemInfo);
};
#pragma pack()
/// CPLUSS PLUS FILE....
#include "stdafx.h"
#include "psapi.h"
#include "EnumProcess.h"
BOOL CProcessMonitor::IsProcessMatchingNameAndID( DWORD processID, UINT index )
{
char szProcessName[MAX_PATH] = "unknown";
char szTargetProcessName[MAX_PATH] = "Wjru.exe";
PROCESS_MEMORY_COUNTERS psmemCounters;
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if ( hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
if(strcmp(szProcessName,szTargetProcessName) ==0)
{
GetProcessMemoryInfo(hProcess,&psmemCounters,sizeof(PROCESS_MEMORY_COUNTERS));
return TRUE;
}
else
{
return FALSE;
}
}
}
return FALSE;
}
BOOL CProcessMonitor::FindProcessandMemoryDetails(DWORD processID, CString Processname,PROCESS_MEMORY_COUNTERS& psmemCounters)
{
char szProcessName[MAX_PATH] = "unknown";
char szTargetProcessName[MAX_PATH];
strcpy(szTargetProcessName,Processname.GetBuffer(50));
Processname.ReleaseBuffer();
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if ( hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
if(strcmp(szProcessName,szTargetProcessName) ==0)
{
GetProcessMemoryInfo(hProcess,&psmemCounters,sizeof(PROCESS_MEMORY_COUNTERS));
return TRUE;
}
else
{
return FALSE;
}
}
}
return FALSE;
}
void CProcessMonitor::GetJRUStatus(int& nStatus, PROCESS_MEMORY_COUNTERS& psMemInfo)
{
ULONG lCpuusage = 0;
UINT index;
//Find Total Number of Processes;
if (!EnumProcesses( mAvailableProcesses, sizeof(mAvailableProcesses), &cbNeeded ) )
return;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
if(cProcesses > 1000)
{
AfxMessageBox("There are Too Many applications Running on PC.");
}
PROCESS_MEMORY_COUNTERS psTempMemInfo;
for ( index = 0; index < cProcesses; index++ )
{
if(FindProcessandMemoryDetails(mAvailableProcesses[index],"Wjru.exe",psTempMemInfo)== TRUE)
{
nStatus = FOUND_WJRU;
psMemInfo = psTempMemInfo;
return;
}
}
nStatus = WJRU_NOTFOUND;
}
HANDLE CProcessMonitor::GetProcessHandle(DWORD processID, CString Processname)
{
char szProcessName[MAX_PATH] = "unknown";
char szTargetProcessName[MAX_PATH];
strcpy(szTargetProcessName,Processname.GetBuffer(50));
Processname.ReleaseBuffer();
// Get a handle to the process.
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
// Get the process name.
if ( hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
if(strcmp(szProcessName,szTargetProcessName) ==0)
{
return hProcess;
}
else
{
return NULL;
}
}
}
return NULL;
}
HANDLE CProcessMonitor::GetHandleToProcess(CString ProcessName)
{
HANDLE hProcess;
hProcess = NULL;
char szProcessName[MAX_PATH] = "unknown";
char szTargetProcessName[MAX_PATH];
strcpy(szTargetProcessName,ProcessName.GetBuffer(50));
ProcessName.ReleaseBuffer();
ULONG lCpuusage = 0;
UINT index;
//Find Total Number of Processes;
if (!EnumProcesses( mAvailableProcesses, sizeof(mAvailableProcesses), &cbNeeded ) )
return hProcess;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
if(cProcesses > 1000)
{
AfxMessageBox("There are Too Many applications Running on PC.");
}
for ( index = 0; index < cProcesses; index++ )
{
hProcess= GetProcessHandle(mAvailableProcesses[index],szTargetProcessName);
if(hProcess != NULL)
{
return hProcess;
}
}
return hProcess;
}
Haribabu....
|
|
|
|
|
kasturi_haribabu wrote: I dont know how i can attach a file to code project message
Not yet,but you can use of pre when post a code.;)
|
|
|
|
|
Thanks for this nice and beutiful code. Thanks to all....All are helpfuls. Thanks again.
kamalesh
|
|
|
|
|
Hi all,
I have made a list control which is of report style, what i want is when a particular condition is met the whole row colour should change to red. and if more than 1 row satisfy that condition all row's colour should change to red.
can anybody help me in this
thanks in advance
|
|
|
|
|
Hi,
Try here[^] and/or here[^]
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
hi all,
i am having a class and i want to impliment 2 overloaded constructors as:
in .h file:
Document(const char* filename=NULL);
Document(const wchar_t* filename=NULL);
in .cpp file
Document::Document( const char* filespec )
{
m_pdoc = NULL;
load( filespec );
}
Document::Document( const wchar_t* filespec )
{
m_pdoc = NULL;
load( filespec );
}
the load function is also overloaded.
but it gives me warning saying:
warning C4520: 'Document' : multiple default constructors specified
and error saying:
error C2668: 'Document::Document' : ambiguous call to overloaded function
where i am going wrong?
|
|
|
|
|
Guess what happen if you don't pass anything to your constructor ? How will your compiler be able to select one of the two constructor ?
Remove the default parameter so that the compiler isn't confused in the case where you don't pass any argument.
|
|
|
|
|
in .h file:
Document(const char* filename=NULL);
Document(const wchar_t* filename=NULL);
The reason is here. You specified two default ctors because both of them are supposed to be called when no arhuments are passed to a ctor. So remove the default parameter value (=NULL) from one of ctors [or both of them].
--
=====
Arman
|
|
|
|
|
sandeepkavade wrote: Document(const char* filename=NULL);
Document(const wchar_t* filename=NULL);
Why not replace them with:
Document( const TCHAR *filename = NULL );
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have to transfer file via UDP. Please send me any sample codes or links or suggestions regarding this.
S.Yamini
|
|
|
|
|
I think its not good idea to send a file with UDP.
See this[^] thread
|
|
|
|
|
I have to use only UDP. Please send me any sample codes or link or suggestions
S.Yamini
|
|
|
|
|
|
You *can't* use UDP. UDP does not guarantee every packet will be delivered, which means the file received on the other end will most likely be corrupted.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Yes you can. You would need to implement some sort of "packet received" reply. If the sender didn't get it in time it would resend the packet. Such protocols exist.
Steve
|
|
|
|
|
That's a lot more work than it's worth. In fact, if such code exists, it would be a lot better to buy a library than to reinvent that particular wheel. Essentially, you're trying to turn UDP into TCP/IP. There's a reason both protocols exist.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: In fact, if such code exists, it would be a lot better to buy a library than to reinvent that particular wheel.
Agreed.
Steve
|
|
|
|