|
What is the value of m_pConnection at this point? I would suggest you add some code to check that your variables contain correct values.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
sorry for the mistake
I mean that the dll installed with the Installer causes crash.
but the dll I just compile (debug or release version) works well.
I think the problem is at this level (i'm not sure):
m_pConnection->Open(bstrConnectionString, wstrSuperUserDB.c_str(), wstrSACUserPassword.c_str(), Internal::adConnectUnspecified);
(this is using a log file)
Is this related to the creation of version installer or something else ?!
|
|
|
|
|
is it crashing *inside* that call, is m_pConnection valid, are the strings valid? What is the behaviour?
COM is normally very good at letting you know, via error codes, what's wrong
The installer should create no differences
|
|
|
|
|
if we considerate that Installer not make difference , why crash only on version installer ?
How know what is wrong via error codes?
|
|
|
|
|
when you find the crash, the answer will probably present it
It sounds like you have a problem you'll have to debug - again, are the pointers valid, are the parameters valid?
Another option is attach to the running version, either in Visual Studio, or with WinDebug, but, again, compile without optimisations, and make sure you generate PDB files
|
|
|
|
|
sorry for the mistake
I mean that the dll installed with the Installer causes crash.
but the dll I just compile (debug or release version) works well.
I think the problem is at this level (i'm not sure):
m_pConnection->Open(bstrConnectionString, wstrSuperUserDB.c_str(), wstrSACUserPassword.c_str(), Internal::adConnectUnspecified);
(this is using a log file)
Is this related to the creation of version installer or something else ?!
|
|
|
|
|
I'm not sure if this is possible but I would like to run some code every time a print job is started by any Windows application. Is there a method of detecting that this has happened? Like a message or something similar?
|
|
|
|
|
 use JOB_INFO struct
The JOB_INFO structures contain a Status member and a pStatus member. Both members contain status information of a print job reported by the port monitor. These two members differ in that the Status member is a bit field of states that contains predetermined values, while the pStatus member is a pointer to a string that could contain just about anything.
BOOL GetJobs(HANDLE hPrinter,
JOB_INFO_2 **ppJobInfo,
int *pcJobs,
DWORD *pStatus)
{
DWORD cByteNeeded,
nReturned,
cByteUsed;
JOB_INFO_2 *pJobStorage = NULL;
PRINTER_INFO_2 *pPrinterInfo = NULL;
if (!GetPrinter(hPrinter, 2, NULL, 0, &cByteNeeded))
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return FALSE;
}
pPrinterInfo = (PRINTER_INFO_2 *)malloc(cByteNeeded);
if (!(pPrinterInfo))
return FALSE;
if (!GetPrinter(hPrinter,
2,
(LPSTR)pPrinterInfo,
cByteNeeded,
&cByteUsed))
{
free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
if (!EnumJobs(hPrinter,
0,
pPrinterInfo->cJobs,
2,
NULL,
0,
(LPDWORD)&cByteNeeded,
(LPDWORD)&nReturned))
{
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
}
pJobStorage = (JOB_INFO_2 *)malloc(cByteNeeded);
if (!pJobStorage)
{
free(pPrinterInfo);
pPrinterInfo = NULL;
return FALSE;
}
ZeroMemory(pJobStorage, cByteNeeded);
if (!EnumJobs(hPrinter,
0,
pPrinterInfo->cJobs,
2,
(LPBYTE)pJobStorage,
cByteNeeded,
(LPDWORD)&cByteUsed,
(LPDWORD)&nReturned))
{
free(pPrinterInfo);
free(pJobStorage);
pJobStorage = NULL;
pPrinterInfo = NULL;
return FALSE;
}
*pcJobs = nReturned;
*pStatus = pPrinterInfo->Status;
*ppJobInfo = pJobStorage;
free(pPrinterInfo);
return TRUE;
}
BOOL IsPrinterError(HANDLE hPrinter)
{
JOB_INFO_2 *pJobs;
int cJobs,
i;
DWORD dwPrinterStatus;
if (!GetJobs(hPrinter, &pJobs, &cJobs, &dwPrinterStatus))
return FALSE;
if (dwPrinterStatus &
(PRINTER_STATUS_ERROR |
PRINTER_STATUS_PAPER_JAM |
PRINTER_STATUS_PAPER_OUT |
PRINTER_STATUS_PAPER_PROBLEM |
PRINTER_STATUS_OUTPUT_BIN_FULL |
PRINTER_STATUS_NOT_AVAILABLE |
PRINTER_STATUS_NO_TONER |
PRINTER_STATUS_OUT_OF_MEMORY |
PRINTER_STATUS_OFFLINE |
PRINTER_STATUS_DOOR_OPEN))
{
free( pJobs );
return TRUE;
}
for (i=0; i < cJobs; i++)
{
if (pJobs[i].Status & JOB_STATUS_PRINTING)
{
if (pJobs[i].Status &
(JOB_STATUS_ERROR |
JOB_STATUS_OFFLINE |
JOB_STATUS_PAPEROUT |
JOB_STATUS_BLOCKED_DEVQ))
{
free( pJobs );
return TRUE;
}
}
}
free( pJobs );
return FALSE;
}
|
|
|
|
|
Thanks for this information.
After a bit more research I actually found a completely different method of doing this using the "FindFirstPrinterChangeNotification" function. You can register for an event whenever the job queue changes and then just use "WaitForSingleObject" in the usual way to wait for the event to be triggered. This works well and you can even use same function to register for events on other printer related status changes.
|
|
|
|
|
Hello,
I have an Win32 COM application with GUI written in C++ (MFC). This GUI invokes a ATL COM client/DLL that acts as a sink to a ATL COM server. Everything works well. So we have 3 components here- MFC GUI app, COM client/sink and COM event server.
Now, I need to replace this native MFC C++ GUI application with .NET application. So I imported the COM dll that acts as sink into my .NET application and all interfaces were available as expected. When I make a specific method call in this COM dll/object, this method establishes sink connection with COM server (using AtlAdvise) without any issues. However, when the COM server raises an event, the call reaches the sink, but it fails in InvokeFromFuncInfo (specifically it DispCallFunc fails) from ATLCOM.h giving Access Violation error (0xC0000005). So to represent this:
1. .NET GUI ---create instance--->>> COM DLL (SINK) ---establish connection --->>>> COM Event Server
2. COM Event Server ---raise event--->>>ATLCOM.h (in COM sink DLL) fails in DispCallFunc with Access Violation (0xC0000005).
The above flow works perfectly well with my MFC GUI.
Is there anything required for this connectionable object or sink that I may not be setting in my .NET appliaction? How can I at least delve deeper to see what is going on?
thanks!
Vikram
|
|
|
|
|
the obvious thing to check for is that the .net gui still has an instance of the originating com object ...
|
|
|
|
|
The sink callback happens inside the COM object. In other words, when sink establishes connection with connectionable object and then expects event from COM server, the execution control is still inside the COM sink. So the instance is alive while this happens.
Could there be anything on .NET security side that I might be missing?
|
|
|
|
|
|
Thanks a lot! The specific section you gave a link for does look like what I am trying to do. Thanks 
|
|
|
|
|
Good link...What I am trying to do is slightly different though. In the post, the event sink is the .NET application it self. In my case, the event sink is another COM object and this sink COM object is instantiated from .NET application.
|
|
|
|
|
The only other thing that comes to mind is the Dispatch pointer you're getting ..
I notice you're using dispatch based callbacks into the sink?
Perhaps (and i'm stabbing in the dark here .Net creates your object as an aggregate object and the IDispatch you get when you query your sink, is not your's it's .NET's ?
|
|
|
|
|
if you import you dll in .net application,you can assign the sink method to your interface directly
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
hello all .
Actually i want to catch a Wrong Password Attempt to logon a system. Is there any API that can lead me to that event. If there is no then how would i be able to catch that event.
|
|
|
|
|
There is no specific event for that since Windows is not logged on so no applications are running at that time, beyond a few system services. You can learn more about the logon process here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Roughly, it should be possible to:
1. Enable Logon auditing in group policy.
2. Subscribe to that particular event using Event Log API's EvtSubscribe[^]
Your program would need to run as a service, because it's possible that noone is logged in at the very moment. I have to little detailed understandiong of the matter toto provide better help, btu that might get you started.
|
|
|
|
|
So here is my problem, I have a c library that I am compiling under CygWin.
I am using Swig to generate a c# wrapper class to it. So I follow the steps to do this. And everything compiles, etc... however..
the defined export names of the functions and constants etc have entry points named in the following fashion:
"swe_sol_eclipse_when_glob"
when I do a 'dumpbin -exports' on the dll the entry points are being named in the fashion of:
"swe_sol_eclipse_when_glob@28"
Is there a way to get rid of the '@xxx' from the names during compilation ?
The makefile is like this:
CFLAGS = -fpic -D MAKE_DLL -g -O9 -Wall # for Linux and other gcc systems<br />
OP=$(CFLAGS) <br />
CC=cc #for Linux<br />
<br />
# compilation rule for general cases<br />
.o :<br />
$(CC) $(OP) -o $@ $? -lm<br />
.c.o:<br />
$(CC) -c $(OP) $< <br />
<br />
SWEOBJ = swedate.o swehouse.o swejpl.o swemmoon.o swemplan.o swepcalc.o sweph.o\<br />
swepdate.o swephlib.o swecl.o swehel.o Sweph_wrap.o<br />
<br />
swetest: swetest.o libswe.a<br />
$(CC) $(OP) -o swetest swetest.o -L. -lswe -lm<br />
<br />
swemini: swemini.o libswe.a<br />
$(CC) $(OP) -o swemini swemini.o -L. -lswe -lm<br />
<br />
# create an archive and a dynamic link libary fro SwissEph<br />
# a user of this library will inlcude swephexp.h and link with -lswe<br />
<br />
libswe.a: $(SWEOBJ)<br />
ar r libswe.a $(SWEOBJ)<br />
<br />
libswe.so: $(SWEOBJ)<br />
$(CC) -shared -o libswe.so $(SWEOBJ)<br />
<br />
clean-swig:<br />
rm -f ../../testsweph
An example of an export is this:
#define EXP32 __declspec( dllexport )
.
.
ext_def(int32) swe_heliacal_ut(double tjdstart_ut, double *geopos, double *datm, double *dobs, char *ObjectName, int32 TypeEvent, int32 iflag, double *dret, char *serr);
An example of the generated c# wrapper:
<pre lang="cs">[DllImport("libswe.dll", EntryPoint="CSharp_swe_heliacal_ut")]
public static extern IntPtr swe_heliacal_ut(double jarg1, HandleRef jarg2, HandleRef jarg3, HandleRef jarg4, string jarg5, HandleRef jarg6, HandleRef jarg7, HandleRef jarg8, string jarg9);
Swig Generated C Wrapper compiled in...
<pre>SWIGEXPORT void * SWIGSTDCALL CSharp_swe_heliacal_ut(double jarg1, void * jarg2, void * jarg3, void * jarg4, char * jarg5, void * jarg6, void * jarg7, void * jarg8, char * jarg9) {
void * jresult ;
double arg1 ;
double *arg2 = (double *) 0 ;
double *arg3 = (double *) 0 ;
double *arg4 = (double *) 0 ;
char *arg5 = (char *) 0 ;
int32 arg6 ;
int32 arg7 ;
double *arg8 = (double *) 0 ;
char *arg9 = (char *) 0 ;
int32 *argp6 ;
int32 *argp7 ;
int32 result;
arg1 = (double)jarg1;
arg2 = (double *)jarg2;
arg3 = (double *)jarg3;
arg4 = (double *)jarg4;
arg5 = (char *)jarg5;
argp6 = (int32 *)jarg6;
if (!argp6) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null int32", 0);
return 0;
}
arg6 = *argp6;
argp7 = (int32 *)jarg7;
if (!argp7) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null int32", 0);
return 0;
}
arg7 = *argp7;
arg8 = (double *)jarg8;
arg9 = (char *)jarg9;
result = swe_heliacal_ut(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
{
int32 * resultptr = (int32 *) malloc(sizeof(int32));
memmove(resultptr, &result, sizeof(int32));
jresult = resultptr;
}
return jresult;
}
|
|
|
|
|
XenobiusII wrote: Is there a way to get rid of the '@xxx' from the names during compilation ?
As far as I recall the @xxx is an offset value used by the linker/loader and is not actually part of the exported name. Try linking with the undecorated name to check that it works correctly.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi everybody i've started learning C++ and i wanna know what are the things that we can do with ? i mean real projects
thks 
|
|
|
|
|
You can do more or less anything with C++, there are very few limitations. I would suggest you spend some time browsing the articles[^] here on CodeProject to see some interesting examples.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi
I have created my own CWnd Class named CShell my problem is OnChar function not called
here with i have attached the code sample
#pragma once
// CShell
class CShell : public CWnd
{
DECLARE_DYNAMIC(CShell)
public:
CShell();
virtual ~CShell();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnPaint();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
private:
CStringArray m_shellText;
int m_cxChar,m_cyChar,m_cxCaps;
TEXTMETRIC m_tm;
public:
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
};
// Shell.cpp : implementation file
//
#include "stdafx.h"
#include "CommandLine.h"
#include "Shell.h"
// CShell
IMPLEMENT_DYNAMIC(CShell, CWnd)
CShell::CShell()
{}
CShell::~CShell()
{}
BEGIN_MESSAGE_MAP(CShell, CWnd)
ON_WM_CHAR()
END_MESSAGE_MAP()
void CShell::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
//CWnd::OnChar(nChar, nRepCnt, nFlags);
}
|
|
|
|
|