|
Hmm... I don't have 64-bit compiler at home, otherwise I could give you a working code snippet...
Maxwell Chen
|
|
|
|
|
Just curious to know that why casting required on return value of GetCurrentProcess()?
GetCurrentProcess return value is HANDLE. I have some knowledge about 64 bit windows that int,long are 32 bit size whereas pointer is of size 64 bit, so casting is required between int,long to pointer and vice versa.
Why do you we need casting on this case ?
I really appreciate your helping tendency and your time.
Thanks in advance.
John
|
|
|
|
|
Yeah... HANDLE should also have been typedef ed...
Maxwell Chen
|
|
|
|
|
Yeah. It has been typedef as long*. But still no need for casting. Right?
Thanks in advance.
John
|
|
|
|
|
Wait...
Could you use [Go to definition], and paste the code snippet for
#ifdef AMD64 // Or x64 something
typedef PVOID HANDLE;
#else // WIN32
#endif
Maxwell Chen
|
|
|
|
|
Hi,
Previously suggestion is also not working. I still got stuck with compilation error.
Any suggestion would be highly appreciated.
Thanks in advance.
Thanks in advance.
John
|
|
|
|
|
I am at office now. I just copied your code snippet and compiled with VC++2005 Pro in x64 mode. It compiles without errors.
typedef BOOL (__stdcall * STACKWALKPROC)
( DWORD, HANDLE, HANDLE );
void main(int argc, char *argv[])
{
STACKWALKPROC _StackWalk64;
_StackWalk64 = (STACKWALKPROC)::GetProcAddress(NULL, "StackWalk64");
1>------ Build started: Project: KeyFD, Configuration: Release x64 ------
1>Compiling...
1>main.cpp
1>Linking...
1>Generating code
1>Finished generating code
1>Embedding manifest...
1>Build log was saved at "file://e:\Wrkshp\KeyFD\x64\Release\BuildLog.htm"
1>KeyFD - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Maxwell Chen
|
|
|
|
|
Hi,
I have a win 32 console application which will spawn a telnet window (Telnet.exe -l username) by using CreateProcess() API call and then pass the password (read from a file by the parent process) to the child process (Telnet window) using anonymous pipes. I have tried with the following code which i got from MSDN and partially modified , but could not get the result.
Please help me how can i pass data to telnet window so that it will logon automatically.
#include <stdio.h>
#include <windows.h>
#define BUFSIZE 4096
HANDLE hChildStdinRd, hChildStdinWr, hChildStdinWrDup,
hChildStdoutRd, hChildStdoutWr, hChildStdoutRdDup,
hInputFile, hStdout, hStdInput,hProcess;
PROCESS_INFORMATION piProcInfo;
BOOL CreateChildProcess(VOID);
VOID WriteToPipe(VOID);
VOID ReadFromPipe(VOID);
VOID ErrorExit(LPTSTR);
VOID ErrMsg(LPTSTR, BOOL);
DWORD main(int argc, char *argv[])
{
SECURITY_ATTRIBUTES saAttr;
BOOL fSuccess;
// Set the bInheritHandle flag so pipe handles are inherited.
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
// Get the handle to the current STDOUT.
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
hStdInput = GetStdHandle(STD_INPUT_HANDLE);
// Create a pipe for the child process's STDOUT.
if (! CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
ErrorExit("Stdout pipe creation failed\n");
// Create noninheritable read handle and close the inheritable read
// handle.
fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd,
GetCurrentProcess(), &hChildStdoutRdDup , DUPLICATE_SAME_ACCESS,
FALSE,
DUPLICATE_SAME_ACCESS);
if( !fSuccess )
ErrorExit("DuplicateHandle failed");
CloseHandle(hChildStdoutRd);
// Create a pipe for the child process's STDIN.
if (! CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
ErrorExit("Stdin pipe creation failed\n");
// Duplicate the write handle to the pipe so it is not inherited.
fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdinWr,
GetCurrentProcess(), &hChildStdinWrDup, DUPLICATE_SAME_ACCESS,
FALSE, // not inherited
DUPLICATE_SAME_ACCESS);
if (! fSuccess)
ErrorExit("DuplicateHandle failed");
CloseHandle(hChildStdinWr);
// Now create the child process.
fSuccess = CreateChildProcess();
if (! fSuccess)
ErrorExit("Create process failed");
// Get a handle to the parent's input file.
if (argc == 1)
ErrorExit("Please specify an input file");
hInputFile = CreateFile(argv[1], GENERIC_READ, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, NULL);
if (hInputFile == INVALID_HANDLE_VALUE)
ErrorExit("CreateFile failed\n");
// Write to pipe that is the standard input for a child process.
WriteToPipe();
// Read from pipe that is the standard output for child process.
// ReadFromPipe();
hProcess = piProcInfo.hProcess;
WaitForSingleObject(hProcess,INFINITE);
CloseHandle(piProcInfo.hProcess);
CloseHandle(piProcInfo.hThread);
return 0;
}
BOOL CreateChildProcess()
{
STARTUPINFO siStartInfo;
BOOL bFuncRetn = FALSE;
const char* lpAppName ="C:\\Windows\\System32\\Telnet.exe";
char* lpCmd = "open 10.41.37.239 -l guest";
// Set up members of the PROCESS_INFORMATION structure.
ZeroMemory( &piProcInfo, sizeof(PROCESS_INFORMATION) );
// Set up members of the STARTUPINFO structure.
ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
siStartInfo.cb = sizeof(STARTUPINFO);
siStartInfo.hStdError = hChildStdoutRdDup;
siStartInfo.hStdOutput = hChildStdoutRdDup;
siStartInfo.hStdInput = hChildStdinWrDup;
// Create the child process.
bFuncRetn = CreateProcess(lpAppName,
lpCmd, // command line
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
CREATE_NEW_CONSOLE, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&siStartInfo, // STARTUPINFO pointer
&piProcInfo); // receives PROCESS_INFORMATION
if (bFuncRetn == 0)
{
ErrorExit("CreateProcess failed");
}
else
{
//CloseHandle(piProcInfo.hProcess);
//CloseHandle(piProcInfo.hThread);
return bFuncRetn;
}
return 0;
}
VOID WriteToPipe(VOID)
{
DWORD dwRead, dwWritten;
CHAR chBuf[BUFSIZE];
memset(chBuf,0,BUFSIZE);
// Read from a file and write its contents to a pipe.
ReadFile(hInputFile, chBuf, BUFSIZE, &dwRead, NULL);
WriteFile(hStdInput, chBuf, dwRead, &dwWritten, NULL);
// Close the pipe handle so the child process stops reading.
if (! CloseHandle(hChildStdinWrDup))
ErrorExit("Close pipe failed");
}
VOID ReadFromPipe(VOID)
{
DWORD dwRead, dwWritten;
CHAR chBuf[BUFSIZE];
memset(chBuf,0,BUFSIZE);
// Close the write end of the pipe before reading from the
// read end of the pipe.
if (!CloseHandle(hChildStdoutWr))
ErrorExit("CloseHandle failed");
// Read output from the child process, and write to parent's STDOUT.
ReadFile( hChildStdoutRdDup, chBuf, BUFSIZE, &dwRead,
NULL);
WriteFile(hStdout, chBuf, dwRead, &dwWritten, NULL);
}
VOID ErrorExit (LPTSTR lpszMessage)
{
fprintf(stderr, "%s\n", lpszMessage);
ExitProcess(0);
}
Thanks in advance.
Best Regards
Viswa
Visweswara Koduri
|
|
|
|
|
Hi, I'm developing a Windows Application with MFC and C++. I've added to the solution a Visual Studio Setup Project and it's installing everything ok. The problem is that now I want to configure the installer so it sets some permissions (I need "everyone full control") in my application folder, inside "Program Files", and I don't find how to do it.
I would really appreciate any clue that could help me to solve this problem.
Thanks!
Federico
PS: I'm using Visual Studio .NET 2003
|
|
|
|
|
i've wierd question in mind ...but as im naive to VC so askin it....is it possible to make a code portable for both embedded systems written in WINCE evc4 mfc and vc++ mfc in winx p
|
|
|
|
|
Yes definitely. I develop WinCE MFCish software and most of the development is done on XP. The very great majority of the code runs fine on XP built with VS2005 ( We used to use VC6 ) and on CE built with EVC4. You have to be a little careful which CRT functions you call as the CRT on CE is a bit limited and keep the MFC as simple as possible but it works without too many issues.
One thing to watch is that threading is handled completely differently on CE. It has a deterministic priority based threading model so no low priority thread ever gets a look in if a higher priority one is busy looping.
If you want portable code across CE and XP then develop for CE and port to XP is the way to go. EVC4 is also a stricter compiler in some ways than MSVC so you'll probably get unexpected warnings if you go the other way. I'm not sure why you'd want to do this except for development purposes but if you've got some killer app that everyone's goign to want on their PDAs and their desktops then why not.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks alot for clearifying my query... actually my work is bit different , i am working for software development for a PC104 board( kind of embedded PC having processor ,seriral ports ,usb stuff like that) which got WINCE installed.. Now i am not getting the idea that for its software development Is EVC4.0 is compatibale or not...or its just for the PDA's...if U can Guide me it would be great..thanks
-- modified at 16:00 Friday 24th August, 2007
|
|
|
|
|
Yes, but WinCE is limited as you can see in help documentation.
Code for WinCE using EVC first, then migrate to XP. Should be painless.
Gary
|
|
|
|
|
Hi All,
I am using ListCtrl on my dialogbox. In this ListCtrl I load JPEG images
When I select any image in ListCtrl then selected image gets disapper. I want JPEG images should not be disapper when user select it. So if any have solution to this ,then please forward it.
Thanks in Advance
Atul
|
|
|
|
|
How did you import images to the listctrl?
|
|
|
|
|
How to bind a application written in VC++ with a system (during installation or at the time of first time applicaiton execution)?
I want to bind my aaplication for particular period. After that period application can't be used with activation.
How to do it in VC++?
|
|
|
|
|
what to you mean by "bind" ??
installing ?
|
|
|
|
|
Binding to a system is difficult and not very user friendly but if you have to then there are two well known methods. Either the MAC Address of the primary network card if your app requires network connectivity and most PCs have one anyway. Or failing that the Serial Number of the primary hard drive. Microsoft use the latter for binding installations of Office and the like so if you move your system to a new disk it stops working until you plug the original CD back in.
All of these systems are vulnerable to hacks, probaby won't hold together on virtual machines and tend to be very, very annoying to the user if they ever go wrong. I hope what you're writing is valuable enough to make it worth the effort.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Do you want to cycle life for your program and then user must buy your program,right?
|
|
|
|
|
yes u r right.
how to do it.
|
|
|
|
|
Aniket Salunkhe wrote: After that period application can't be used with activation.
"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
|
|
|
|
|
that means, if i have given test version of my application to user for 1 month period; then after 1 month user can't use my application without activating it with proper serial kay.
Is there any way to do it in VC++ OR at the time of making Installation (of my VC++ exe)? I am using Inno Setup to make the installation.
|
|
|
|
|
Aniket Salunkhe wrote: that means, if i have given test version of my application to user for 1 month period; then after 1 month user can't use my application without activating it with proper serial kay.
That changes things entirely, as "with activation" and "without activating" are completely different.
Aniket Salunkhe wrote: Is there any way to do it in VC++ OR at the time of making Installation (of my VC++ exe)?
Sure. Most folks will write some obscure key to the registry. Another less-popular way is writing to some out-of-the way file.
"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
|
|
|
|
|
Any body with linkson free e-books for visual c++ 6.0
plz
prubyholl@gmail.com
Thanks
phatkin
|
|
|
|
|
|