|
Your ISAPI dll is just another dll except that it is called by a web server instead of an application. You can call the traditional device context functions to print, such as CreateDC("WINSPOOL", "HP LaserJet 5P", NULL, NULL) and StartDoc, StartPage, gdi drawing functions, EndPage, EndDoc, DeleteDC, or you can opt to write directly to the print spooler with functions such as OpenPrinter, StartDocPrinter, StartPagePrinter, WritePrinter, EndPagePrinter, EndDocPrinter, and ClosePrinter.
The only real restrictions are that you should not create any windows, nor should you assume that you can access network resources, since your dll may be running under the localsystem account.
If you choose the DC method, you can use the WINAPI functions with HDC handles, or choose to use the MFC CDC class.
onwards and upwards...
|
|
|
|
|
I have created a ActiveX control using ATL.
The ATL control houses an MFC based control (that is use in other app). The ActiveX library also makes uses of some code that uses sockets and is multithreaded. The DLL itself is a CWinApp based class.
The problem is that when the DLL registers itself, all the initialization calls work fine, but when the closing ExitInstance call is made, it hangs while I try and clean up a thread, first telling the thread to stop, and then calling
WaitForSingleObject( threadHandle, INFINITE );
to wait till it's gone. This works fine when the code is used in an EXE, but used as part of the ActiveX DLL it just hangs.
Is there some trick I am missing to making an ATL based ActiveX control work with multiple worker threads?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
How are you telling the tread to stop? If you control is Apartment threaded and you make an incoming call to the thread that created an (COM) object after you have told the thread to stop, you must pump messages as you wait for a worker thread to stop.
Try replacing the WaitForSingleObject with MsgWaitForMultipleObjects - including a message pump. Do a search for MsgWaitForMultipleObjects on MSDN, there is an example in there somewhere.
If that doesn't work try posting the code for the worker thread (the main 'loop' of it) along with what you do to make it stop.
|
|
|
|
|
Hey everyone,
I was wondering what would be the best way for me to prevent memory leaks in my application. I was also wondering if anyone could tell me how to test or check for memory leaks possibly caused by my application? Thanks in advance for your help!!
|
|
|
|
|
|
I will diffently try this out......Thanks John!
|
|
|
|
|
I use it with my development and it helps a lot.
John
|
|
|
|
|
BrockVnm wrote:
I was wondering what would be the best way for me to prevent memory leaks in my application.
Good coding practice will remove all but a few "documented" leaks in the OS/frameworks.
if on Windows and using MFC, you can and should use the DEBUG_NEW macros to help you trace some of the memory leaks.
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
BrockVnm wrote:
what would be the best way for me to prevent memory leaks in my application.
Follow some simple rules:
1. Use smart pointers rather than "raw" ones. I reccomend ones from the Boost library. Watch for circular references when you use reference counted ones.
2. If you must use raw pointers, before every new put a comment like: "Who is responsible for deleting this?" and make sure that a matching delete is called in all scenarios.
3. If appropriate, look for some garbage collector library. At least one of them can be found on Code Project, and the most popular one is Boehm's[^].
|
|
|
|
|
Nemanja Trifunovic wrote:
If you must use raw pointers, before every new put a comment like: "Who is responsible for deleting this?" and make sure that a matching delete is called in all scenarios.
Or do what I do - as soon as you write a new statement, immediately write the corresponding delete statement. Same with any other memory allocation.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi All,
Iam not able to delete a directory, which has more than three dot(.)s in its name using SHFileOperation. But iam able to delete directory will two dot(.)s. Why this happens?
Eg. Iam able to delete directory named "1212.1212". But, Iam not able to delete directory named "192.168.1.133".
I get message as
"Cannot delete file: cannot read from source file or disk".
but the directory is present.
How can i delete this directory??
Is this due to Dos Name problem??
With Best Regards,
A.Ilamparithi
|
|
|
|
|
At a guess, it looks like the directory name is being interpreted as an IP address. You may need to prepend additional information ro fully qualify the actual location of the directory.
e.g.
"C:\192.168.1.133"
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
Hi
I tried with full pathname only like the one you mentioned above.
eg.
SHFILEOPSTRUCT shFileOp;
ZeroMemory(&shFileOp, sizeof(SHFILEOPSTRUCT));
_TCHAR *p="c:\\temp\\temp1\\192.168.1.133";
shFileOp.hwnd=NULL;
shFileOp.wFunc=FO_DELETE;
shFileOp.pFrom=p;
//shFileOp.fFlags=FOF_SILENT/*|FOF_NOCONFIRMATION*/;
SHFileOperation(&shFileOp);
Regards,
A.Ilamparithi
|
|
|
|
|
Isn't the filename supposed to be double null termainated. That may cause a problem...
Address of a buffer to specify one or more source file names. These names can be either fully qualified paths, or standard DOS wild cards such as "*.*". Although this member is declared as a null-terminated string, it is used as a buffer to hold multiple file names. Each file name must be terminated by a single NULL character. An additional NULL character must be appended to the end of the final name to indicate the end of pFrom.
John
|
|
|
|
|
the windows explorer can view files as thumbnails. i have image files with my very special format, and i would like that the explorer shows also thumbnails for this files. how does this work? atl? com? ...
|
|
|
|
|
Hi everyone,
I have a DLL with some classes in it. Header file have dllexport feature on class.
This class has some methods, several of them are virtual.
So, the problem is that my test app looking for Foo method in DLL, but can't find it because in DLL it's defined as FooA, but not Foo.
Can somebody tell me what's wrong?
In this [post^] I describe situation in detailes with some code examples.
Thanks in advance,
va'Lery.
|
|
|
|
|
I'm not positive on this, but I believe the A specifies that the function is cdecl. I'd double-check the calling conventions.
--
Joel Lucsy
|
|
|
|
|
Thanks for an idea.
I tried all three possible conventions, but result is still the same.
So that's not it.
va'Lery
|
|
|
|
|
I suspect that in the DLL, the function has the same name as a Windows function whose header you have included, while you haven't included the same header in the application.
Example: the Windows header WinBase.h defines the functions DeleteFileA and DeleteFileW . It also maps the name DeleteFile via a macro to DeleteFileA or DeleteFileW depending on whether the UNICODE symbol is defined. This allows you to switch between using the ANSI and Unicode versions of the functions simply by defining or undefining UNICODE .
Unfortunately the macro processor has no idea of scope and doesn't realise that you actually wanted to refer to a class member function rather than to refer to the Windows function, so it replaces your Foo with FooA.
Solutions: either rename the function, or #undef the macro. If you #undef the macro, consider using #pragma push_macro and #pragma pop_macro to store and retrieve the macro value (supported in VC 6.0, even though undocumented).
Using #undef in this way is a real hassle, though, so I'd simply rename the offending function.
|
|
|
|
|
That's it!
You're absolutely right.
Thanks a lot!
|
|
|
|
|
Hello!
use UndName.Exe and pass full decorated function name to see it's full undecorated name.
|
|
|
|
|
//......... struct for passing info to Escape........
struct Buff
{
DWORD BufLength;
char str[256];
};
//..............This is the code snippet................
char* outPut=(char*)malloc(sizeof(char)*256);
CString sControlCode;
CDC cdc;
cdc.CreateDC(NULL, m_cmbPrinters, NULL, NULL);
DOCINFO di;
::ZeroMemory(&di, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "My Doc";
cdc.StartDoc(&di);
cdc.StartPage();
sControlCode.Format("%x%x",27,'E');
cdc.TextOut(12,34,"Hello Test Out here .... ");
Buff b;
int index=0;
char *p=sControlCode.GetBuffer(256);;
while(*p!='\0')
{
b.str[index++]=*p;
p++;
}
b.str[index++]='\0';
b.BufLength = sControlCode.GetLength();
int s=PASSTHROUGH;
if(cdc.Escape( QUERYESCSUPPORT, sizeof(int) , (const char*)&s , strlen(outPut) , outPut ))
{
cdc.Escape( PASSTHROUGH, 0 , (LPCSTR) &b , strlen(outPut) , outPut );
}
cdc.TextOut( 0, 150, "PASSTHROUGH Escape Function" );
cdc.EndPage();
cdc.EndDoc();
cdc.DeleteDC();
//..................
The printer code "ESC E" for the Epson LX 1050+ enables emphasized printing.
When i use the WritePrinter Api i pass the printer code as '\x1b\x45' and it works fine.The next line gets printed in bold.The WritePrinter Api needs handle to printer device but i need to do the printing through the device context.So the only way to pass printer code is via Escape.But when i pass the string via "Escape" the printer doesn't see it as a command,it just sees it as some non-printable character.So,how do i give printer commands via escape.Please,can someone help me out?
|
|
|
|
|
I suspect that your buffer b does not contain the two bytes of value x1B and E. Try hardcoding the Escape call to pass "\x1BE" and a length of 2.
EX: cdc.Escape(PASSTHROUGH,2,"\x1BE",NULL);
onwards and upwards...
|
|
|
|
|
I tried this code.
EX: cdc.Escape(PASSTHROUGH,2,"\x1BE",NULL);
But i'm getting the following compile time error.
: error C2022: '446' : too big for character.
i tried this code in this manner also.
EX: cdc.Escape(PASSTHROUGH,2,"\x1B\x45",NULL);
now the complie time error gone but it's gives a "memory could not be read" run time error.
Hope you will be able to nail it down.
|
|
|
|
|
Are you compiling with unicode?
onwards and upwards...
|
|
|
|
|