cURL / Mailing Lists / curl-library / Single Mail


(no subject)

From: Timothy B. Ward <>
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.

bool CRegistry::SetNameValue(HKEY hKeyRoot, LPCTSTR pszSubKey, LPCTSTR pszValue, LPTSTR pszBuffer, DWORD& rdwSize)
  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((lRes=RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_READ, &hKey))!=ERROR_SUCCESS) {
        return false;
lRes = RegQueryValueEx(hKey, pszValue, NULL, &dwType, (unsigned char*)pszBuffer, &dwBufferSize);
    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_slist_free_all (headerlist);
        throw ERROR_WRONG_TYPE;
    if(lRes!=ERROR_SUCCESS) {
        return false;


 return true;

Do You Yahoo!?
Get your free address at
Received on 2001-12-19