Click here to Skip to main content
12,829,458 members (40,045 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++
I have .h and .lib and .dll files and I have Lost .cpp file, I need to know if i can recover it(.cpp) from .h or .dll or .lib files. And i have built them by using mfc vc++. Yhanks Alot for help.

Posted 19-Nov-12 7:36am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If the content from a cpp file was in the h file, then what would be the point of the cpp file in the first place. Of course you can't recover a cpp file from the header. You can, however, use the header to know the functions that were defined in the cpp.
In the case of a dll, I suppose you may find a decompiler out there that would do some of the work for you, but you're likely out of luck and will need to rewrite the file.
NOTE: This is why ALL code that is written should be saved in a code repository consistently so that these things don't happen.
wadeaa 19-Nov-12 13:06pm
Thanks for reply, the code is so much huge to rewrit it again do you know sir and good decompiler for doing such a thing?
Marcus Kramer 19-Nov-12 13:15pm
I don't because I don't really trust them.
In the future you should make sure to use source control and backups to ensure that you don't lose stuff again.
Sergey Alexandrovich Kryukov 19-Nov-12 15:59pm
Agree, a 5.
And I added quite a practical advice on what to do: to focus on future. Please see.
Albert Holguin 20-Nov-12 14:21pm
I agree, decompilers are usually not very good at all. +5
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

It's too late to restore the code. Like it or not, writing the code again can be still easier then decompilation.

You should rather forget about the lost code and concentrate of the future efforts. And, for the immediate future, you should realize: right now, you are not really developing code and care about your valuable code asserts, because you are not using Revision Control Systems,[^].

You should start using one immediately, not tomorrow, but today. It can be open-source and free, well maintained, extremely lightweight and, most importantly, extremely dependable. Please see this discussion:
Revision control systems, which to choose from?[^].

For some more information on some particular systems, please see my past answers:
Needs some words of wisedom to set up and/or use a server[^],
Make an unclickable form[^],
How can i structured to arrange source code when i create a new solution[^],
Reviews at Apache Subversion[^].

Marcus Kramer 19-Nov-12 16:07pm
+5. Nice.
Sergey Alexandrovich Kryukov 19-Nov-12 16:31pm
Thank you, Marcus.
Albert Holguin 20-Nov-12 14:22pm
Good advice... +5
Sergey Alexandrovich Kryukov 20-Nov-12 14:31pm
Thank you, Albert.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You could try some of these suggestions[^], but be prepared for a lot of work. Unless your LIB/DLL was built with debug information the decompilers have to make a lot of guesses as to the structure of the original source.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170326.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100