|
CONTAINING_RECORD is just a macro that defined as folow:
#define CONTAINING_RECORD(address, type, field) ((type *)( (PCHAR)(address) - (UINT_PTR)(&((type *)0)->field)))
Why would you need templates to do that?
|
|
|
|
|
because then I just need a function as operator * in the template class!
Don't try it, just do it!
|
|
|
|
|
Is there anybody who can help me by developping an ISAPI FILTER on a ISA SERVER 2000, please?????
|
|
|
|
|
Thats a lot of help to ask for on a Discussion forum.
Still I can try, if you care.
Due Regards
Mahendra
|
|
|
|
|
Hi Mahendra,
are you ready for my questions? so, let's start:
FIRST QUESTION:
How can I get the client's browser's session ID?
For each browser does an ID exist?
SECOND QUESTION
I would like to know why the following code for the event OnAuthComplete is not working; I have already declared the method and caught the notification (SF_NOTIFY_AUTH_COMPLETE: dwRet = OnAuthComplete(pfc, (PHTTP_FILTER_AUTH_COMPLETE_INFO))pvNotification); :
HANDLE TokenHandle = (HANDLE)1;
DWORD dwLen = 0;
PTOKEN_USER pTokenUser = NULL;
DWORD dwErr;
char name[MAX_NAME], domain[MAX_NAME];
// Get user token.
if ( pAuthCompInfo->GetUserToken(pfc,&TokenHandle) )
{
// Get token information size.
if ( !GetTokenInformation(TokenHandle,TokenUser,NULL,dwLen,&dwLen) )
{
dwErr = GetLastError();
if ( ERROR_INSUFFICIENT_BUFFER == dwErr )
{
// Alocate buffer for token information.
pTokenUser = (PTOKEN_USER)GlobalAlloc(GPTR,dwLen);
dwErr = S_OK;
}
}
// Now get the actual token information.
if ( dwErr != S_OK ||
!GetTokenInformation(TokenHandle, TokenUser,pTokenUser,dwLen,&dwLen) )
{
return WriteIntoFile(pfc, "Evento OnAuthComplete: ERRORE 1");
}
else // We have the token information in hand.
{
// Extract from the token information - the SID.
SID *pSid = (SID *)pTokenUser->User.Sid;
DWORD dwNLen = MAX_NAME, dwDLen = MAX_NAME;
SID_NAME_USE eUse;
// Get the user name and the domain from the SID.
if (!LookupAccountSid(NULL,pSid,name,&dwNLen,domain,&dwDLen,&eUse) )
{
return WriteIntoFile(pfc, "Evento OnAuthComplete: ERRORE 2");
}
else
{
return WriteIntoFile(pfc, "Evento OnAuthComplete: User name:" + *name);
// name buffer contains user name.
// domain buffer contains user domain.
}
}
}
SQLPOINTER sp = name;
long userID = GetUserID(sp);
return WriteIntoFile(pfc, "Evento OnAuthComplete: ");
}
WriteIntoFile is a method that write into a file and I have already tested it and it works well.
I have other question but I start just with the two first question.
Thanks a lot.
|
|
|
|
|
how to set item with different color subitems in CListCtrl?
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
|
Is he really your son, or are just speaking "Metaphorically"?
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
thats what I was gonna say...
Good to see i'm not the only one whose feeling a little smart a$$ today... (or everyday in my case).
How do I print my voice mail?
|
|
|
|
|
Roger Allen wrote:
Is he really your son,
Dear god, nooooo! (no offence George, I'm sure you would have been a fantastic son).
I Dream of Absolute Zero
|
|
|
|
|
comb and shave, goat-beard boy
http://www.adga.org[^]
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
I suppose your control already has the LVS_REPORT style.
In the window or dialog containing the CListCtrl, add a NM_CUSTOMDRAW notification. Then just code the different colors you wish in the added notification method, like in the following example (for more information, see:
Customizing a Control's Appearance Using Custom Draw, in MSDN
Owner-draw CListCtrl MFC app at http://www.simtel.net/pub/pd/15298.shtml)
void CTestListCtrlDlg::OnNMCustomdrawList1(NMHDR *pNMHDR, LRESULT *pResult)<br />
{<br />
LPNMLVCUSTOMDRAW pNMCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR);<br />
<br />
*pResult = 0; <br />
<br />
switch(pNMCD->nmcd.dwDrawStage)<br />
{<br />
case CDDS_PREPAINT:<br />
*pResult = CDRF_NOTIFYITEMDRAW;<br />
break;<br />
<br />
case CDDS_ITEMPREPAINT:<br />
<br />
*pResult = CDRF_NOTIFYSUBITEMDRAW;<br />
break;<br />
<br />
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:<br />
switch(pNMCD->iSubItem) {<br />
case 0:<br />
switch(pNMCD->nmcd.dwItemSpec) {<br />
case 0:<br />
pNMCD->clrText = RGB(0,0,0);<br />
pNMCD->clrTextBk = RGB(0,255,255);<br />
break;<br />
default:<br />
pNMCD->clrText = RGB(0,0,0);<br />
pNMCD->clrTextBk = RGB(255,255,255);<br />
break;<br />
}<br />
break;<br />
case 1:<br />
pNMCD->clrText = RGB(255,0,0);<br />
pNMCD->clrTextBk = RGB(255,255,0);<br />
break;<br />
default:<br />
pNMCD->clrText = RGB(0,0,0);<br />
pNMCD->clrTextBk = RGB(255,255,255);<br />
break;<br />
}<br />
*pResult = CDRF_DODEFAULT;<br />
break;<br />
<br />
default:<br />
*pResult = CDRF_DODEFAULT;<br />
break;<br />
}<br />
}
Friendly yours, Chris
|
|
|
|
|
thanks, that was good help
were rgrtgrtvrtrt rtrtb brt tyuhjghj hbhbnh hnjm 1234567?
|
|
|
|
|
Take a look at this[^]. But of course learning custom draw by yourself is always strongly recommended, my... uh, friend.
|
|
|
|
|
hi all,
here is my problem
i want to call a api(ReadFile) fucnction which return the byte array . how i have to declare and pass variables from managed c++.
i am comfortable with receving normal datatypes like int, char. but i can't get the array
please help me.
thankyou
|
|
|
|
|
I need to download huge files over HTTP, using Wininet, and it seems that the only function available to provide information about a file's length is InternetQueryDataAvailable . The problem is that it only returns the length of a chunk available by a call to InternetReadFile
I would like to provide the status of the download in a progress control, therefore i need the total length of the file before the operation begins.
Any ideea?
rechi
|
|
|
|
|
|
|
I want to get a value from a dll,codes as below:
#pragma data_seg(".TimeDATA")
static HWND hCallHook=NULL;
static HHOOK hHook=NULL;
static HINSTANCE hins=NULL;
static char LastEventTimebuf[19]="";
#pragma data_seg()
#pragma comment(linker,"/SECTION:.TimeDATA,RWS")
CRegulardll1App theApp;
HANDLE mutex=NULL;
CRegulardll1App::CRegulardll1App()
{
}
BOOL CRegulardll1App::InitInstance ()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return TRUE;
}
BOOL CRegulardll1App::ExitInstance ()
{
return TRUE;
}
LRESULT __declspec(dllexport)__stdcall CALLBACK GetMsgProc(int nCode,WPARAM wParam,LPARAM lParam)
{
COleDateTime oleLogDate = COleDateTime::GetCurrentTime();
CString strCurTime = oleLogDate.Format("%Y-%m-%d %H:%M:%S");
if(NULL == mutex)
return CallNextHookEx(hHook, nCode,wParam, lParam);
WaitForSingleObject(mutex,INFINITE);
strcpy(LastEventTimebuf,strCurTime);
ReleaseMutex(mutex);
}
}
return CallNextHookEx(hHook, nCode,wParam, lParam);
}
BOOL __declspec(dllexport)__stdcall installhook(HWND hCallProc)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
mutex=CreateMutex(NULL,FALSE,"timemutex");
if(NULL == mutex)
return FALSE;
hCallHook=hCallProc;
hHook=SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)GetMsgProc,hins,0);
return TRUE;
}
BOOL __declspec(dllexport)__stdcall UnHook()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
BOOL unhooked = UnhookWindowsHookEx(hHook);
CloseHandle(mutex);
return TRUE;
}
BOOL __declspec(dllexport) __stdcall GetLastEventTime(char* pBuf,int size)
{
if(NULL == pBuf || size<19)
return FALSE;
else
{
WaitForSingleObject(mutex,INFINITE);
CString str(LastEventTimebuf);
strcpy(pBuf,str);
ReleaseMutex(mutex);
}
return TRUE;
}
when I call GetLastEventTime in my application,the program is shut down. I don't how to use mutex correctly. please tell me what I should to,thanks a lot
|
|
|
|
|
You are creating the mutex in installhook which is called from you app. The mutex handle, mutex, is not shared, so any other process that tries to access mutex (via GetMsgProc) will always get a NULL mutex.
At the begining of GetMsgProc do OpenMutex to set the "mutex" variable for that process to the acutal mutex handle.
Just a personal thing - MFC in hook DLL is a performance killer. And a pain in the arse to boot.
|
|
|
|
|
Diddy,my code is below after modified:
GetMsgProc()
{
HANDLE m_hmutex=NULL;
m_hmutex=OpenMutex(NULL,FALSE,"timemutex");
if(NULL == m_hmutex)
return CallNextHookEx(hHook, nCode,wParam, lParam);
WaitForSingleObject(m_hmutex,INFINITE);
strcpy(LastEventTimebuf,strCurTime);
ReleaseMutex(m_hmutex);
}
BOOL __declspec(dllexport)__stdcall installhook(HWND hCallProc)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
mutex=CreateMutex(NULL,FALSE,"timemutex");
if(NULL == mutex)
return FALSE;
hCallHook=hCallProc;
hHook=SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)GetMsgProc,hins,0);
return TRUE;
}
mutex is also shared,but that problem still exist.
|
|
|
|
|
Change it to:
m_hmutex=OpenMutex(MUTEX_ALL_ACCESS,FALSE,"timemutex");
Also, in BOOL __declspec(dllexport)__stdcall installhook(HWND hCallProc)
Change:
hHook=SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)GetMsgProc,hins,0);
To:
hHook=SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)GetMsgProc,AfxGetInstanceHandle(),0);
If that doesn't fix it - all I can suggest is its the way you are calling the GetLastEventTime function from your EXE - how are you declaring the exported functions in the EXE? Like this:
BOOL __declspec(dllimport)__stdcall installhook(HWND hCallProc);
BOOL __declspec(dllimport)__stdcall UnHook();
BOOL __declspec(dllimport) __stdcall GetLastEventTime(char* pBuf,int size)
??
Or are you calling via loadlibray/getprocaddress?
|
|
|
|
|
#pragma data_seg(".TimeDATA")
static HWND hCallHook=NULL;
static HHOOK hHook=NULL;
static HINSTANCE hins=NULL;
static HANDLE m_hmutex=NULL;
static char LastEventTimebuf[19]="";
#pragma data_seg()
#pragma comment(linker,"/SECTION:.TimeDATA,RWS")
// CRegulardll1App construction
CRegulardll1App theApp;
CRegulardll1App::CRegulardll1App()
{
}
BOOL CRegulardll1App::InitInstance ()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
hins=AfxGetInstanceHandle();
return TRUE;
}
BOOL CRegulardll1App::ExitInstance ()
{
CloseHandle(m_hmutex);
return TRUE;
}
LRESULT __declspec(dllexport)__stdcall CALLBACK GetMsgProc(int nCode,WPARAM wParam,LPARAM lParam)
{
PMSG pmsg;
pmsg = (PMSG)lParam;
if (nCode >= 0)
{
if((pmsg->message==WM_KEYDOWN || (pmsg->message==WM_MOUSEMOVE)||(pmsg->message==WM_NCLBUTTONDOWN)||(pmsg->message==WM_NCLBUTTONDBLCLK)
||(pmsg->message==WM_LBUTTONDOWN)||(pmsg->message==WM_RBUTTONDOWN)||(pmsg->message==WM_RBUTTONUP)||(pmsg->message==WM_LBUTTONDBLCLK)||(pmsg->message==WM_RBUTTONDBLCLK)))
{
COleDateTime oleLogDate = COleDateTime::GetCurrentTime();
CString strCurTime = oleLogDate.Format("%Y-%m-%d %H:%M:%S");
m_hmutex=OpenMutex(MUTEX_ALL_ACCESS,FALSE,"timemutex");
WaitForSingleObject(m_hmutex,INFINITE);
strcpy(LastEventTimebuf,strCurTime);
ReleaseMutex(m_hmutex);
}
}
return CallNextHookEx(hHook, nCode,wParam, lParam);
}
BOOL __declspec(dllexport)__stdcall installhook(HWND hCallProc)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
m_hmutex=OpenMutex(MUTEX_ALL_ACCESS,FALSE,"timemutex");
hCallHook=hCallProc;
hHook=SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)GetMsgProc,AfxGetInstanceHandle(),0);
return TRUE;
}
BOOL __declspec(dllexport)__stdcall UnHook()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
BOOL unhooked = UnhookWindowsHookEx(hHook);
return TRUE;
}
BOOL __declspec(dllexport) __stdcall GetLastEventTime(char* pBuf,int size)
{
if(NULL == pBuf || size<19)
return FALSE;
else
{
WaitForSingleObject(m_hmutex,INFINITE);
CString str(LastEventTimebuf);
strcpy(pBuf,str);
ReleaseMutex(m_hmutex);
}
return TRUE;
}
Application:
HINSTANCE hinstDLL=LoadLibrary("regulardll1.dll");
if(hinstDLL)
{
typedef BOOL GetLastEventTime(char* ,int);
GetLastEventTime* p=(GetLastEventTime*)GetProcAddress(
hinstDLL, "GetLastEventTime");
if(NULL != p)
{
char buf[19]="";
if(p(buf,sizeof(buf)))//Problem happens here
{
CString str(buf);
MessageBox(hWnd,str,"",MB_OK);
}
}
}
|
|
|
|
|
Yes - because:
typedef BOOL GetLastEventTime(char* ,int);
is very different to the way GetLastEventTime is declared:
BOOL __stdcall GetLastEventTime(char* ,int);
You will be screwing up the stack when you call a __stdcall function with __cdecl calling convention (which is the default).
Change it to:
typedef BOOL __stdcall GetLastEventTime(char* ,int);
And it should work.
|
|
|
|
|
thank you very much,I have made a mistake.
|
|
|
|
|