curl-library
(no subject)
Date: Wed, 19 Dec 2001 10:04:34 -0500
Hi, I wrote some time ago about the problems I was having getting weird page faults on some machines and not others using the same code.
It was suggested to me that I make sure that the string I was trying to add was in fact \0 terminated.
I have done so, and I am still experiencing these problems.
and /all help would be appreciated.
I'm getting the name of the computer from the registry and I'm trying to post that information to a php webpage.
This code isn't complete, but this is the function in question.
<code>
bool CRegistry::SetNameValue(HKEY hKeyRoot, LPCTSTR pszSubKey, LPCTSTR pszValue, LPTSTR pszBuffer, DWORD& rdwSize)
{
HWND HWND;
CURL *curl;
CURLcode res;
struct HttpPost *formpost=NULL;
struct HttpPost *lastptr=NULL;
struct curl_slist *headerlist=NULL;
char buf[] = "Expect:";
HKEY hKey;
DWORD dwType = REG_SZ;
LONG lRes;
DWORD dwBufferSize = rdwSize;
if(!pszBuffer)
throw ERROR_INVALID_BUFFER;
if((lRes=RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_READ, &hKey))!=ERROR_SUCCESS) {
SetLastError(lRes);
return false;
}
lRes = RegQueryValueEx(hKey, pszValue, NULL, &dwType, (unsigned char*)pszBuffer, &dwBufferSize);
RegCloseKey(hKey);
rdwSize = dwBufferSize;
if (strstr(pszBuffer, "\0")) {
MessageBox(NULL, pszBuffer, "Die", MB_OK);
}
curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "name",CURLFORM_COPYCONTENTS, pszBuffer, CURLFORM_END);
headerlist = curl_slist_append(headerlist, buf);
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://myhostip/report.php");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
curl_formfree(formpost);
curl_slist_free_all (headerlist);
}
if(dwType!=REG_SZ)
throw ERROR_WRONG_TYPE;
if(lRes!=ERROR_SUCCESS) {
SetLastError(lRes);
return false;
}
return true;
}
</code>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Received on 2001-12-19