|
You could post an encrypted version of the username and password (or at least just MD5 the password) in a query sent to the website, and parse the response.
This[^] article can help you implement the client side portion of the task. You'll obviously need server side support also.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I need a function, which gives me the handle to an active Window. I currently use the FindWindow function, but it also returns handles to already destroyed windows (which come from the same application that ran before and was closed). I found the IsWindow function and currently use it in combination with FindWindow, which looks like the following:
private int GetExistingWindow(string cl, string name)
{
int hWnd;
while(true)
{
if((hWnd = WM.FindWindow(cl, name)) == 0)
StartProcess();
if(WM.IsWindow(hWnd))
break;
}
return hWnd;
}
questions:
1) Can I do it that way (means returns a second call of FindWindow another handle than the first one or do I always get the same)
2) Is there a better method (single function, etc.)
Thanks
BTW: The code is written in C#(functions are well implemented), but due to the fact that it is a Win32 API question I decided to post it here.
|
|
|
|
|
well the proplem is that in win32 you can not get a valid handle to a window in another application this is some type of protection that windows do to protect applications from affecting each other
|
|
|
|
|
I'm not sure what you are referring to but FindWindow() does exactly what you indicate is not possible - it returns a handle to a top-level window given either the window's name or class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
what code i can use to connect all visual c++ programs i created?
calling visual c++ program to another visual c++ program using a button.
thank you!
|
|
|
|
|
TO EXECUTE A PROGRAM use ShellExecute(...) read more in msdn .
keep smilling.....b'coz smile is the shortest distance between people....
|
|
|
|
|
Hi,
I am building an dll. in the dlll app i declared some variables. while accessing the variables the assertion of access denied. while on constructor of the app there is no problem for variables after that unable to access the variables. so currently i declare the variables outside of the class(global) there is no problem in this case. Any one help to me.
Thanks in Advance.
Have A Nice Day!
Murali.M
|
|
|
|
|
use at the declaration of the class
__declspec (dllexport)
and make sure the variables are public or private with get/set methods!
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
I tried to optimize some mathematical calculation by adding assembler code using
SSE, but i have some problem:
I got two dimensional array of floats, and i don't know how to reserve memory for
it, I tried next way :
__declspec(align(16)) float** m_FirstArray = (float**)
_aligned_malloc(ARRAY_SIZE*sizeof(float),16);
for(int i = 0;i
|
|
|
|
|
First off, I would like to thank you for taking the time to see this problem. I'm sort of a n00b when it comes to using COM objects, and unfortunately the way I'm learning has a really steep learning curve. Basically, I am trying to create a program that writes to Word, and I'm having a bit of a problem passing objects to the COM objects that I instantiate - specifically the Range and Section objects. So let me order my questions:
1) How do I correctly create a new Range object so I can add it to a Section object?
2) How do I add the Range object to the Section? (According to the VBA documentation, the Sections collection object has an Add method that takes a Range object as its first argument [MFC specifies it as a VARIANT parameter type] and placement as a second argument).
Basically this is the way I see it, but I don't know how to do it:
1) Create new Range object.
2) Set information in Range object.
3) Add new Section using Sections.Add(new_range_obj, placement)
If anybody has any code that I can look at in an existing solution that interfaces with Word that would be awesome. I usually learn better by looking at code and seeing what it does anyways. Thanx!
|
|
|
|
|
Hi folks,
Where i can find the diference between C++ and VC++?.
Please send me link or material.
|
|
|
|
|
The main difference between regular C++ and Visual C++ is just that Visual C++ works a lot with Microsoft's frameworks, specifically .NET (if its Visual C++.NET) and MFC. You can still write standard C++ applications in VC++ with/without the Microsoft frameworks, however getting the Microsoft frameworks to work with other IDEs is difficult, yet possible if you really know how to do it. Microsoft does not release it's MFC framework, so in order to use it you would have to get VC++. In terms of IDE, its a matter of preference, otherwise its purely what you can and can not do between C++ and VC++. Just remember, everything you do in VC++ you could do in standard C++, but it would just take longer because you don't have all the pre-defined objects for Windows development that Microsoft provides as part of VC++.
Hope that helps.
|
|
|
|
|
C++ is a programming language, Visual C++ is a compiler/IDE for the C++ programming language.
|
|
|
|
|
The thing is that C++ is the language, and VC++ is just the environment that you can program in C++. It is like writing English text in Notepad- the language is English, but you write it in Notepad. But you can also write it in Word, WordPad? and so on... so, VC++ is the program(IDE to be more certain), and C++ is the language.
I hope you got it!
keep smilling.....b'coz smile is the shortest distance between people....
|
|
|
|
|
Difficult question! VC++ and C++ are the same thing, the differences lay in what non-standard C++ keywords are specific to the MS-VC++ compiler. Other C++ compilers also have there own non-standard keywords. You can look up MS-VC++ specific keywords in the MSDN library, also many you will see many places in MSDN that state "Microsoft specific", which apply either to keywords of compiler specific instructions.
Your best bet is to get a book on standard C++, like those written by the origanal author of C++ Bjarne Stoustrup or maybe P.J. Plauger (former member of the standards commitee). Once you know what is standard C++, then you will beable to see what is not standard in VC++.
Another source of information are articles on cross platform programming, and also cross platform libraries (there are some at sourceforge.net, as a matter of fact there are lots of projects at sourceforge.net that are cross platform).
P.S. not all compilers are standards compliant, so just because the standard says something is so, does not mean that it is so for a given compiler.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi folks-
I've been searching for answers on this problem for days. Hope someone can help!!
I've got a very basic example application, taken directly from the WinInet HttpSendRequestEx() example on MSDN (http://support.microsoft.com/kb/q177188/). I have to use this function in my appication since a large amount of data must be sent.
My test program works perfectly except when Digest authentication and SSL are being used. In that case only, the call to InternetErrorDlg() raises an access violation exception inside the Wininet DLL.
No SSL works fine. Basic authentication works fine. SSL with Basic Authentication works fine. No SSL with Digest works fine!!!
I'm testing with a free Proxy server called FreeProxy, the only one I could find which supports both Basic and Digest authentication.
I discovered that the HTTP Status code must be checked right after the call to HttpSendRequestEx() (see the code). Code 407 (Proxy authentication required) is returned here when the proxy is running and the next call to InternetWriteFile() will fail.
One other thing I observed is that when using Digest the last call to InternetReadFile() (at the end) to retrieve the response hangs up for about 30 seconds before finally returning normally. This does not happen with Basic authentication.
So the question is... what is causing that access violation inside WinInet when I call InternetErrorDlg()???? Have tried this on Win 2000 and XP.
Also, if anyone knows of another authenticating proxy I can test with that would be great.
Thanks!!
-Nicholas
Here's my code:
BOOL bSecure = TRUE;
HINTERNET hConnect;
if (!bSecure)
hConnect = InternetConnect(hSession, "server.com", INTERNET_DEFAULT_HTTP_PORT,
NULL, NULL, INTERNET_SERVICE_HTTP,NULL, NULL);
else
hConnect = InternetConnect(hSession, "server.com", INTERNET_DEFAULT_HTTPS_PORT,
NULL, NULL, INTERNET_SERVICE_HTTP,NULL, NULL);
HINTERNET hRequest;
if (!bSecure)
hRequest = HttpOpenRequest(hConnect, "POST", "test.cgi",
NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
else
hRequest = HttpOpenRequest(hConnect, "POST", "test.cgi",
NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_SECURE, 0);
INTERNET_BUFFERS BufferIn;
DWORD dwBytesWritten;
int n;
BYTE pBuffer[1024];
BOOL bRet;
BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS ); // Must be set or error will occur
BufferIn.Next = NULL;
BufferIn.lpcszHeader = NULL;
BufferIn.dwHeadersLength = 0;
BufferIn.dwHeadersTotal = 0;
BufferIn.lpvBuffer = NULL;
BufferIn.dwBufferLength = 0;
BufferIn.dwBufferTotal = dwPostSize; // This is the only member used other than dwStructSize
BufferIn.dwOffsetLow = 0;
BufferIn.dwOffsetHigh = 0;
if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, 0, 0)) {
printf( "Error on HttpSendRequestEx %d\n",GetLastError() );
return FALSE;
}
BOOL bHaveProxy = FALSE;
// get the http status code (if any)
DWORD dwStatusCode;
DWORD dwLength = sizeof(dwStatusCode);
if (HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwStatusCode, &dwLength, NULL) &&
dwStatusCode == 407)
bHaveProxy = TRUE; // we're connecting thru an authenticating proxy server
if (!bHaveProxy) { // call to InternetWriteFile() will fail with code 12019 if we got 407
FillMemory(pBuffer, 1024, 'D'); // fill buffer with meaninless data
bRet=TRUE;
for(n=1; n<=(int)dwPostSize/1024 && bRet; n++) {
if(bRet=InternetWriteFile( hRequest, pBuffer, 1024, &dwBytesWritten))
printf( "\r%d bytes sent.", n*1024);
}
if(!bRet) {
printf( "\nError on InternetWriteFile %lu\n",GetLastError() );
return FALSE;
}
}
if(!HttpEndRequest(hRequest, NULL, 0, 0)) {
printf( "Error on HttpEndRequest %lu \n", GetLastError());
return FALSE;
}
// get the http status code (if any)
dwLength = sizeof(dwStatusCode);
if (HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
&dwStatusCode, &dwLength, NULL) && dwStatusCode == 407)
bHaveProxy = TRUE;
// show the proxy login dialog if a proxy was detected (code 407)
if (bHaveProxy) {
// note: this call causes an access violation if using SSL with Digest authentication
InternetErrorDlg(GetDesktopWindow(), hRequest, ERROR_SUCCESS,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS | FLAGS_ERROR_UI_FLAGS_GENERATE_DATA |
FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS, NULL);
}
// read response
DWORD dwBytesRead;
char pcBuffer[512];
printf("\nThe following was returned by the server:\n");
do {
dwBytesRead=0;
if (InternetReadFile(hRequest, pcBuffer, 511, &dwBytesRead)) {
pcBuffer[dwBytesRead]=0x00; // Null-terminate buffer
printf("%s", pcBuffer);
} else
printf("\nInternetReadFile failed");
} while (dwBytesRead>0);
|
|
|
|
|
Why do i get a critical error here in this code. I want to read succesive pages in a process memory
<br />
int main(int argc, char **argv[]) <br />
{<br />
PROCESS_INFORMATION pi; <br />
STARTUPINFO si; <br />
HANDLE hProcess; <br />
BYTE buf[200000]; DWORD bufsize = sizeof buf;<br />
DWORD baseaddr = 0;<br />
LPCVOID lpAddress = 0;<br />
PMEMORY_BASIC_INFORMATION lpBuffer = 0;<br />
DWORD dwLength = 0;<br />
DWORD flNewProtect =0;<br />
PDWORD lpflOldProtect = 0;<br />
DWORD dwSize =0;<br />
LPCVOID lpBaseAddress = 0;<br />
DWORD nSize = 0;<br />
DWORD buff = 0;<br />
LPDWORD lpNumberOfBytesRead = sizeof buf;<br />
if (argc !=2)<br />
{<br />
printf("Error in the input line, Usage: Inputfile");<br />
exit(0);<br />
}<br />
<br />
printf("Process %d creates a child process\n",GetCurrentProcessId());
GetStartupInfo(&si);<br />
<br />
CreateProcess(NULL,<br />
argv[1], NULL, <br />
NULL, <br />
FALSE, CREATE_NEW_CONSOLE, <br />
NULL, <br />
NULL, <br />
&si, <br />
&pi <br />
);<br />
hProcess = pi.hProcess; <br />
printf("New Process ID: %d ",pi.dwProcessId);<br />
printf("has started \n");<br />
<br />
VirtualQueryEx(<br />
hProcess,
lpAddress,
lpBuffer,
dwLength,
GetLastError()<br />
);<br />
VirtualProtectEx(<br />
hProcess,
lpAddress,
dwSize,
flNewProtect,
lpflOldProtect );
<br />
ZeroMemory(buf, sizeof(buf));<br />
if( ReadProcessMemory( hProcess, lpBaseAddress, nSize, bufsize, buff ) == FALSE )<br />
{<br />
printf("\nProcess ID %d ",pi.dwProcessId);<br />
printf (" memory read failed (errcode: %d)", GetLastError());<br />
printf("\nmemory read: \n",&buf);<br />
}<br />
else<br />
{<br />
printf("\nProcess ID %d ",pi.dwProcessId);<br />
printf("memory read: \n",buf);<br />
}<br />
return (0);<br />
}<br />
oam
|
|
|
|
|
Well to start with you can not do things like this:
LPDWORD lpNumberOfBytesRead = sizeof buf;
The variable lpNumberOfBytesRead is a pointer and a pointer holds the address of where the data is stored. What the above line is doing is setting the address to the value sizeof(buf), which is not an address.
Change to:
DWORD NumberOfBytesRead = sizeof(buf);
or this (since its initial value may not matter)
DWORD NumberOfBytesRead = 0;
and pass like this
SomeFunction(...,...,&NumberOfBytesRead);
Now the following from your code, should make any C++ compiler choke (fail with errors):
ReadProcessMemory(
hProcess,
lpBaseAddress,
nSize, // This should be a pointer to buffer
bufsize,
buff ); // This should be a pointer to DWORD
The correct arguments are
ReadProcessMemory( hProcess, lpBaseAddress, buf, bufsize, &NumberOfBytesRead);
or
ReadProcessMemory( hProcess, lpBaseAddress, buf, sizeof(buf), &NumberOfBytesRead);
I have no doudt that there are several other things wrong with this code, but the above should help you get started on figuring out what they are.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Yep i looked at that and there were mistakes, but the main problem comes from the virtualqueryEx function which has to do most of the things. Because i have to read pages using it...
So it gives this error msg:
"The value of ESP was not properly saved across a function call."
error code 5: Illegal function call
error code 998: from virtualqueryex function
oam
|
|
|
|
|
The code you gave should not compile on any compiler period! Let alone give any error messages when run. I can not remember ever seeing so many basic programming errors. If by some miricle it did run, then (Yep) it would probubly crash. Heck you stand a better chance of crashing the whole system than making that code work (as written).
As for VirtualQueryEx: Why are you even trying to call it? The call appears to be used to retrieve information that needs to be stored in the structure pointed to by lpBuffer, but lpBuffer does not point to a structure, it points to NULL. The only reason the dwLength argument is correct, is that it is 0, since lpBuffer is NULL. You are also passing it a 5th argument GetLastError, for who knows what reason (it only takes 4 arguments and this is not one of them).
I recomend you start all over again from scatch. What ever it is you are trying to accomplish, this will not do it.
P.S. Sorry but if I was an employer, the code you gave would get you fired.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
See title , thanks..
Couldn't find the functions using MSDN or google .
|
|
|
|
|
GetFileAttributes(), check the FILE_ATTRIBUTE_DIRECTORY bit.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
bool dirExists
(CString strDirectory)
{
TCHAR* fullPath = _tfullpath (NULL, strDirectory, 0);
if (fullPath == NULL)
return (false);
TCHAR szCurrDir [_MAX_PATH];
_tgetcwd (szCurrDir, _MAX_PATH - 1);
long nStatus = _tchdir (fullPath);
_tchdir (szCurrDir);
free (fullPath);
if (nStatus == 0)
return (true);
return (false);
} /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
We have a driver for low level control for the parallel port using outp inp. However, this driver only works on NT platforms under Administrator. I am trying to find a way to tell the manager that the user has permissions to run this driver.
However, I cannot get access to the manager from my level to do that. How can I change the rights for the program to run under any user?
here is a snipit of code that I have.
// connect to local service control manager
if ((m_hSCMan = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS)) == NULL)
{
AfxMessageBox("Can't connect to service control manager\n\nI am assuming that you are working on a non-NT system.\n\nIf not you will need to investigate the problem", MB_OK);
m_fNT = FALSE;
}
else
{
if (DriverStart(szDriver))
{
AfxMessageBox("Unable to start the driver!\n\n"
"Please try running [loaddrv] to correct this issue.", MB_OK);
}
}
|
|
|
|
|