Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8902879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:43:36+00:00 2026-06-15T01:43:36+00:00

I found the following snippet of code and am trying to create an ISAPI

  • 0

I found the following snippet of code and am trying to create an ISAPI .DLL using it.

#include <windows.h>
#include <httpfilt.h>
#include "tchar.h"
#include "strsafe.h"

// Portion of HttpOnly
DWORD WINAPI HttpFilterProc(
   PHTTP_FILTER_CONTEXT pfc,
   DWORD dwNotificationType,
   LPVOID pvNotification) {

   // Hard coded cookie length (2k bytes)
   CHAR szCookie[2048];
   DWORD cbCookieOriginal = sizeof(szCookie) / sizeof(szCookie[0]);
   DWORD cbCookie = cbCookieOriginal;

      HTTP_FILTER_SEND_RESPONSE *pResponse = 
         (HTTP_FILTER_SEND_RESPONSE*)pvNotification;

      CHAR *szHeader = "Set-Cookie:";
      CHAR *szHttpOnly = "; HttpOnly";
      if (pResponse->GetHeader(pfc,szHeader,szCookie,&cbCookie)) {
         if (SUCCEEDED(StringCchCat(szCookie,
                                    cbCookieOriginal,
                                    szHttpOnly))) {
            if (!pResponse->SetHeader(pfc,
                                      szHeader,
                                      szCookie)) {
                        // Fail securely - send no cookie!
                        pResponse->SetHeader(pfc,szHeader,"");
               }
            } else {
               pResponse->SetHeader(pfc,szHeader,"");
          }
   }

   return SF_STATUS_REQ_NEXT_NOTIFICATION;
}

I created a new C++ project using VS 2010 Express. I get the following error when I build the project:

------ Build started: Project: ISAPIHttpOnly, Configuration: Debug Win32 ------
  HttpOnly.cpp
c:\documents and settings\bob\my documents\visual studio 2010\projects\isapihttponly\isapihttponly\httponly.cpp(25): error C2664: 'StringCchCatW' : cannot convert parameter 1 from 'CHAR [2048]' to 'STRSAFE_LPWSTR'
          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I’m not sure how to resolve this. :S

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:43:38+00:00Added an answer on June 15, 2026 at 1:43 am

    Your program is being compiled as Unicode, then STRSAFE_LPWSTR, which is the type from the first parameter in StringCchCat, is failing against an char array type, which is not Unicode.

    To solve this, you have two choices, one is to declare the erroneous string as an TCHAR array, so it can be preprocessed to an wchar_t array. But then you’d have to change a lot of things in your code, like literal trings would need the TEXT("") macro, etc.

    But as it seems, your program was not done to use Unicode strings, so the other choice is to compile your program as Multi-Byte, then you don’t need to change anything in your code because StringCchCat will have a STRSAFE_LPSTR parameter, which will be preprocessed to char *.

    To compile as Multi-Byte, just go to Project Settings->General->Character Set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found the following code snippet here : with TClipper.Create do try AddPolygon(subject, ptSubject);
I'm trying to compile the following snippet of code: #include <boost/filesystem/path.hpp> //Other includes snipped
I have the following assembly code snippet I am trying to understand. It is
I found the following code snippet: List[T] forSome { type T } The forSome
After hours of Googling on this subject matter, I found the following code snippet
I have the following snippet of code and I'm trying to run it from
I'm trying to include a Google Maps widget in my admin-interface using this snippet
In this tutorial I've found the following snippet: deposit :: (Num a) => a
I found a script which has the following snippet:- userid=`expr \`id\` : .*uid=[0-9]*(\(.[0-9a-z]*\)) .*`
I found the following piece of code from the adw launcher: Object service =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.