I am new in in Visual Studio Win32 (C++) Applications
In java where I work, logging is easy using log4j for instance.
How is the logging done in a Win32 app?
I have seen some code using macros to write to files.
Am I responsible to create some logging mechanism?
Is there a standard way to log in win32?
Thanks
Use the Event Log API to write to Windows Event Log
http://msdn.microsoft.com/en-us/library/aa385772(v=vs.85).aspx
Another way is using log4net since you have experience of log4j, there are very similar.
"Windows application" doesn't mean much of anything, Java apps can also run on Windows. There's log4net to adding logging to a .NET application. Log4cxx to do so for an app written in C++. Exact same approach as log4j. The project's home page is here.
It depends on who is going to be using your software's logging facility:
The Windows Event Log API is best if you are writing a service or "system" type task that needs to be supported by an IT support department. Support tools for Windows support remote access of system event logs to create system health alerts and so on.
Other than that, Windows does not have a convenient Logging API. So you need to roll-your own if the system event log is inappropriate.
For developers / debugging purposes theres OutputDebugString that will emit text to your debuggers "Output" window.
It is convenient when writing GUI apps, to make the debug build a console application, so that a console window is displayed in addition to the GUI. printf() can display messages to the console.
Otherwise, some OSS projects I built on windows did include a variant of log4c that had been ported to windows. So log4c can be coerced into working on windows if you really need it.
Related
From this post i see we can run un-managed code in azure.
Running Native Code
My question is do we have access to all Win32 API's in azure, or are there any limitations. In general are there any limitations (which some of you may have come across) in running un-managed code in azure.
Thanks
Nakago...
Most Win32 APIs will work fine. But please note Windows Azure is a service environment, so in general it doesn’t make sense to call APIs like CreateWindowsEx.
In addition, by default, only core OS components are installed. Please install libraries like ATL yourself, if you wish to use them (via startup task or custom VM image). Please also manually enable Desktop Experience to use certain OS features. From my experience, I’ve tried to use Direct2D (to process images, but not render them) and Media Foundation, it doesn't encounter any issues.
Best Regards,
Ming Xu.
I know that I can use ReportEvent method to write event logs in windows. But it seems to me that this method is useful for logging events prior to Windows Vista and 7 event log changes. For example, I don't think I can create a custom application log, set sessionID, ... using this library.
My other option will be using the System::Diagnostics methods like WriteEntry. This one has the features that I'm looking for, but the problem is that I can only use it in /clr mode.
My question is: is there any unmanaged C++ library for logging events to Windows 7?
Cheers,
Reza++
Thanks #Luke, the answer is ETW. For writting to event logger, you can not use the legacy API and you should use the manifest-based providers.
Use a text UI library. The Curses library used to be a popular option, but it is limited by copyrights.
Fortunately, there is an uncopyrighted version available.
This is called the "Console" mode.
Depending on your development environment and language of choice, it can be as simple as Ctrl+Shift+N, "Console Project" (in Visual Studio), or tweaking compiler flags (for C++). Every IDE/language provide a way to do this.
In Windows, the Console operates in two ways. Firstly, any project can create, attach to, and modify any number of console windows whenever it wants. Secondly, with a special flag in the EXE, the project will start up already attached to a console.
The latter operates subtly differently from the former. If you want a "normal" console application, I strongly suggest against creating and attaching to consoles. Just use the Console mode compiler setting.
Clipper was a popular way to do this in DOS.
I guess this is an old Clipper program. I so, there is still active support and even GUI libraries. I suggest you try xharbour. It's not DOS anymore but pure windows based. There is a free version and a pay version (visual xHarbour). With this tool you can even access SQL databases and it's 100% clipper compatible.
I am talking about a small game engine using C# for game programming.
So, I have a C++ app embedding mono runtime (I call it 'launcher'). And I have an assembly written in C# which is my game engine class library. The launcher launches the assembly as it is suggested in Embedding Mono.
And now the interesting part!
The launcher implements in C++ miscelaneous functions which are exposed to the mono runtime as internal methods of my game engine classes. That is why my game engine assembly is nothing without the launcher which implements a huge part of the engine in C++.
The question: How am I supposed to debug my C# assembly? And what is more important, how am I supposed to debug a Game which I am going to write in C# ???
As you understand I cannot debug the assembly using MonoDevelop Debugger because it won't receive internal C++ implementations of some of its methods.
What I need is to run the Launcher. The launcher then will launch C# assembly using embedded mono runtime. And then I need something to connect to the launched assembly to allow its debugging.
Or any other way. Thank you!
I recommend using the Mono Soft Debugger. It's been included in the Mono runtime since Mono 2.6, and is more reliable than the old hard debugger, and also much more portable.
The Mono soft debugger can be started by passing options using the --debugger-agent commandline argument to the Mono runtime. This can be done from an embedding host by constructing a fake set of commandline arguments and passing it to mono_jit_parse_options. For example, the Moonlight browser plugin uses the debugger agent values from MOON_SOFT_DEBUG environment variable if it is set.
Typically debugger options are something like
--debugger-agent="transport=dt_socket,address=$ADDRESS:$PORT"
which will cause the app to try to connect to debugger listening on the given address, and pause until it establishes a connection. Note that the connection is established over TCP/IP, which means remote debugging is very easy to set up, and even on the local machine you would use localhost. Additional options are documented on Mono's man page.
The other piece you need is the debugger GUI/controller, to listen for the connection from your app, and handle stepping/visualizing, etc. I would suggest using MonoDevelop. There's a library for the debugger wire protocol called Mono.Debugger.Soft.dll, but it's fairly low-level, and although Mono Tools for Visual Studio supports connecting to the soft debugger, it's not yet extensible in a way that would allow debugging Mono embedding hosts.
Using MonoDevelop to accept debugger connections from embedding hosts currently requires creating an addin, but this is fairly straightforward. Take a look at the Moonlight debugger addin for an example. For simple use cases I would suggest that you don't define a whole new project type but just create a debug handler that handles existing DotNetExecutionCommand projects, so you can run->run with...->your custom debugger.
The monodevelop-list mailing list is a good resource if you have more questions.
Make use of network debugging.
You could use the Soft Debugger to debug the Mono parts, and then use remote debugging for the C++ parts.
I did some googling to try to answer this question but even after that I'm not quite clear about something. Is it possible to create a console app from VB6?
I've got a VB6 app that doesn't put up a window. I always assumed that it was a console app. However, I want to be able to use the Windows API SetConsoleCtrlHandler function from within it. I believe that with C++/MFC apps you have to set a linker switch to create a console app. And one of my fellow developers told me that VB6 doesn't create a true console app and therefore this would not work. So is it possible to create a console app that Windows will recognize as a console app from VB6?
Platform: Windows XP SP2
Development Platform: VB6
Yes. It's also possible to create totally headless applications (which I've done a few times in the past). This link gives an example with a code snippet.
You can use Karl E. Peterson's code at http://vb.mvps.org/samples/Console/
to create a very full-featured console application.
Simpler ones can be made by relinking the compiled VB6 EXE for the console subsystem. Karl goes into this at that same Web page. Scroll down for LinkConsole.vbs there.
See this article.
Or you could rewrite the VB6 app as a VBScript program.