C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-29-2009, 02:41 AM   #1
Registered User
 
Join Date: Feb 2008
Posts: 93
Avoiding an external dll to printf

Hi

My console application load a DLL via LoadLibrary. When calling this library the dll printf a few lines. Is it possible to avoid the dll to output printing at console from my program?

Thx
Kempelen is offline   Reply With Quote
Old 10-29-2009, 03:18 AM   #2
Registered User
 
Join Date: Sep 2006
Posts: 2,512
You can print on a console window, without a dll. Whatever else the dll is doing for you, you'd have to replace that functionality, by using API calls.

You'll need the source code changed, of course.
Adak is offline   Reply With Quote
Old 10-29-2009, 07:38 AM   #3
Registered User
 
Join Date: Jan 2009
Posts: 30
Before you call the function, redirect stdin to a file (use freopen) and then change it back after calling the function. This function will create a file to redirect the text to, but you can just remove it afterwards.

There are probably other/better ways to do this but this is the only one I can think of at the moment. You may also be able to just change the mode so that the writes to stdin fail but that is most likely undefined.

EDIT: Come to think of it, I'm not 100% sure whether this method will work if the printf call is in another module, but it's worth a try.
DeadPlanet is offline   Reply With Quote
Reply

Tags
dll, printf

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Math calculator and compiler errors littlefermat245 C Programming 2 10-12-2009 09:45 PM
I have some questions :( geekrockergal C Programming 19 02-01-2009 09:44 AM
C++ std routines siavoshkc C++ Programming 33 07-28-2006 12:13 AM
structs and passing information to and from functions Sandy C Programming 4 04-01-2003 12:49 AM
Ask about these "unresolved external symbol" error ooosawaddee3 C++ Programming 1 06-29-2002 11:39 AM


All times are GMT -6. The time now is 05:03 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22