1

I'm pretty new to WinAPI programming, and have written a Win32 application for screen capture. When I run the program, the cursor immediately changes to a crosshair and I can click and drag to capture a portion of the screen and save it to file.

However, I'd now like to modify my program so that it doesn't contain a main method (WinMain) and essentially turn it into an object class rather than an application class so I can call functions from other programs. I haven't been able to find a good resource on how to do this, as I believe WinMain carries out special functionality under the hood so I can't simply change the name of the method.

Can anyone suggest some good resources or tutorials that address this?

1 Answers1

2

There are many ways to do that, but you have fist move one step back:

How do yopu expect your "program" (let us continue to call that way) to be called? With which parameters and what return type?

Then, what kind of API do you want to expose? A C++ class in header? a C++ class from a static library? A C function exported from a DLL? an COM object?

There are many sample on how a library or a DLL or a COM library looks like (just try google those keywords).

The simple way is most likely to set up a library or a DLL project (most IDE have wizard that provide empty skeletons), than paste in it the relevant code that you require to leave there, letting it be called from the exposed function or class method.

A more precise answer can be given only after you decided which "form" your "object" should have.

Emilio Garavaglia
  • 20,229
  • 2
  • 46
  • 63
  • Thanks for your response! Well, ultimately I want my program to return a String. The only parameter it'll need to take in is the id or HWND of a window it'll need to minimise. – user1177250 Feb 21 '13 at 11:37
  • By what means do you intend to call a function in one program from another program? That decision will determine which way you go next. – Raymond Chen Feb 21 '13 at 13:20
  • I'm trying to write a screen capture plugin for a browser, and it requires native code to be able to capture any window/screen portion, not just the browser window. Because I was new to programming for Windows, I implemented the functionality as a standalone application first to become familiar with syntax, etc. I've been using [this](http://http://msdn.microsoft.com/en-us/library/ms235636(v=vs.80).aspx) to start dll work. I'd like to have my screen capture (with its windows and WndProcs) in the dll and be able to call it from another c++ file. – user1177250 Feb 22 '13 at 16:04