msvcr90.dll dependency in VS 2005 C++ project - c++

I've created a DLL project in VS 2005 for native Win32/unmanaged C++, call it myProj.dll. It depends on a 3rd-party commercial DLL that in turn depends on msvcr90.dll (I assume it was built from a VS 2008 project). I'll call it thirdParty.dll.
My DLL project builds just fine in VS2005. I've built a test app (again, VS 2005 Win32 C++) that links to myProj.lib. (As an aside, judging by the small size of the .lib, and by the fact that, at run-time, the app must locate myProj.dll, I'm guessing that the .lib is just a wrapper for a call to loadLibrary() that loads the actual DLL; is that close?)
My problem is that, at run-time, the test app cannot locate msvcr90.dll (nor msvcp90.dll), the dependency on which stems from the thirdParty.dll.
I've installed Microsoft's redist package, and so have all the std (9.0) C++ libraries in c:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_... . What's more, if I point the dependency walker at thirdParty.dll, it happily resolves the references to that location.
But, if I point depends.exe at my test app (.exe) or myProj.dll, msvcr90.dll and msvcp90.dll are not found.
I'm guessing there's something I need to configure in VS2005 so that the .exe or myProj.dll are aware of the location of the 9.0 versions of the std C++ libraries (presumably where the redist package installed them in C:\WINDOWS\WinSxS), but I can't seem to figure out what it is. Am I on the right track?
I note that, if I simply copy the msvc*90.dll files to my app directory, then the dependency is resolved, but I get the run-time error about improper loading of std c++ DLLs, etc.
Thanks immensely in advance.

This looks like a "Side-by-Side Assemblies" issue to me.
From what I can tell, Microsoft in an attempt to stop the DLL Hell problems of past years has introduced a concept of "Side-by-Side Assemblies".
In a nut shell it means that your application needs to tell Windows which version of the CRT it was designed to work with. When the application is installed Windows will make sure you application gets its own private copy of these DLL files.
To make it all work you need to embed the application's DLL dependencies into the applications Manifest file and attaching it to the project using the Manifest Tool, Input and Output section of the application project settings.
As an example here is the manifest I use for the Zeus for Windows IDE:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="Xidicone.Windows.Zeus for Windows"
version="3.9.6.69"
processorArchitecture="X86"
type="win32" />
<description>Zeus for Windows</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.VC80.CRT"
version="8.0.50608.0"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b" />
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>
</assembly>
Finally, if you plan to make an installer you will need to add the same versions of these DLL files to the application installer or alternatively have your installer run the Microsoft CRT redistributable installer.
FWIW I only found out about this when a user reported that Zeus no longer ran on Windows XP because of a missing MSVCRT runtime DLL file, yet Zeus had been working fine for over 10 years without ever once having to ship with a MSVCRT runtime DLL file.

Did you install the SP1 version of the msvc 2008 redist?
It is not a problem if depends.exe cannot find the msvcr90.dll, if you use the microsoft installer it is automatically installed in the correct location, and will be found if your application is run. It does not help if you copy the dll's to your application directory if you do not create a manifest.
But can you tell the exact error message you get?
You can also take a look here and here regarding the manifest.

I would ask the third party dll people about this.

I have the same problem some days ago. myProj.dll depends on a thirdParty.dll, which uses msvcr90. If I build a test.exe using directly myProj.dll, it is ok. But if I use loadLibrary(myProj.dll) in test.exe, the call will just fail. The same would happen if I try loadLibrary(myProj.dll) in a Java program.
After some investigation and research on Internet, the following steps have resolved my problem.
Make sure that NO msvcr90 is on the PATH.
You can use process explorer (procexp.exe of SystemInternals) to find out all msvcr90 currently loaded in your environment. As a matter of fact, starting from VC 2005, C runtime libraries should only be installed in the Global Assembly Cache (\winsxs....), not even under windows, or windows\system32.
embed the dll manifest in myProj.dll.
After cl.exe and link.exe producing myProj.dll, a corresponding manifest is also produced.
Then use mt.exe -inputresource myProj.dll.manifest -out myProj.dll;2
The above solves my problem, hope that it could be of any help to you.
BTW, I am using VC 2008 under Windows 2008 R

Related

How do I resolve error 0xc000007b when sharing my exe file? [duplicate]

I have a client/server app which I have been developing on a single PC. Now it needs two serial ports, so I borrowed a PC from a friend.
When I build my app and try to run or debug it (whether in the Delphi IDE or from Windows File manager), it errors "The application was unable to start correctly (0xc000007b)".
Googling doesn't bring up much, but seems to indicate that this is nothing Delphi specific and happens with other apps. It seems to be caused by calling into a 32 bit DLL from a 64 bit app or vice versa.
both PCs are Windows 7, 64 bit
both have Delphi Xe2 starter edition which can only handle 32 bits
The app runs fine on my PC, but not on my friend's
Other Delphi apps run just fine on both PCs
Can anyone give me a hint as to how to track this down?
Normally we get the 0xC000007B error-code (which means STATUS_INVALID_IMAGE_FORMAT), if:
If a 32-bit app tried to load a 64-bit DLL.
Or if a 64-bit app tried to load a 32-bit DLL.
Or if a 64-bit app tried to run on a 32-bit Windows.
To really know, I would suggest to test whether there is a problem between your application and its dependencies using dependency walker
Note that all you need to do is open your App using said tool, and issues appear as red log-entries at buttom of screen.
(At least, at time of writting, namely 2022)
Also, make sure you run the correct version of Dependency Walker, for example, the x86 version will display incorrect results when openning x64 binaries.
A load time dependency could not be resolved. The easiest way to debug this is to use Dependency Walker. Use the Profile option to get diagnostics output of the load process. This will identify the point of failure and should guide you to a solution.
The most common cause of this error is trying to load a 64 bit DLL into a 32 bit process, or vice versa.
I tried all the things specified here and found yet another answer. I had to compile my application with 32-bit DLLs. I had built the libraries both in 32-bit and 64-bit but had my PATH set to 64-bit libraries. After I recompiled my application (with a number of changes in my code as well) I got this dreaded error and struggled for two days. Finally, after trying a number of other things, I changed my PATH to have the 32-bit DLLs before the 64-bit DLLs (they have the same names). And it worked. I am just adding it here for completeness.
It is a missing dll.
Possibly, your dll that works with com ports have an unresolved dll dependence.
You can use dependency walker and windows debugger. Check all of the mfc library, for example. Also, you can use nrCommlib - it is great components to work with com ports.
It has been mentioned in earlier answers that using dependency walker is the way to go, in my case (my application keeps failing with the error code), dependency walker showed a few dll that are NOT relevant!
Finally figured out that I can run profiling by going to "profile" menu and it will run the application and stop at the exact dll that's cause the problem! I found out a 32bit dll was picked because of path and fixed it.
I experienced the same problem developing a client-server app using Microsoft Visual Studio 2012.
If you used Visual Studio to develop the app, you must make sure the new (i.e. the computer that the software was not developed on) has the appropriate Microsoft Visual C++ Redistributable Package. By appropriate, you need the right year and bit version (i.e. x86 for 32 bit and x64 for 64 bit) of the Visual C++ Redistributable Package.
The Visual C++ Redistributable Packages install run-time components that are required to run C++ applications built using Visual Studio.
Here is a link to the Visual C++ Redistributable for Visual Studio 2015 .
You can check what versions are installed by going to Control Panel -> Programs -> Programs and Features.
Here's how I got this error and fixed it:
1) I developed a 32 bit application using Visual Studio 2012 on my computer.
Let's call my computer ComputerA.
2) I installed the .exe and the related files on a different computer we'll call ComputerB.
3) On ComputerB, I ran the .exe and got the error message.
4) On ComputerB, I looked at the Programs and Features and didn't see Visual C++ 2012 Redistributable (x64).
5) On ComputerB, I googled for Visual C++ 2012 Redistributable and selected and installed the x64 version.
6) On ComputerB, I ran the .exe on ComputerB and did not receive the error message.
I recently had an issue where I was developing an application (that used a serial port) and it worked on all the machines I tested it on but a few people were getting this error.
It turns out all the machines that the error happened on were running Win7 x64 and had NEVER ONCE been updated.
Running a Windows update fixed all of the machines in my particular case.
Actually this error indicates to an invalid image format. However, why this is happening and what the error code usually means? Actually this could be appear when you are trying to run a program that is made for or intended to work with a 64 bit Windows operating system, but your computer is running on 32 bit Operating system.
Possible Reasons:
Microsoft Visual C++
Need to restart
DirectX
.NET Framework
Need to Re-Install
Need to Run the application as an administrator
Source: http://www.solveinweb.com/solved-the-application-was-unable-to-start-correctly-0xc000007b-click-ok-to-close-the-application/
This may be a case where debugging the debugger might be useful. Essentially if you follow the instructions here you can run two ide's and one will debug into the other. If you un your application in one, you can sometimes catch errors that you otherwise miss. Its worth a try.
I have seen the error trying to run VC++ debug executable on a machine which did not have Visual C++ installed. Building a release version and using that fixed it.
In my case the error occurred when I renamed a DLL after building it (using Visual Studio 2015), so that it fits the name expected by an executable, which depended on the DLL. After the renaming the list of exported symbols displayed by Dependency Walker was empty, and the said error message "The application was unable to start correctly" was displayed.
So it could be fixed by changing the output file name in the Visual Studio linker options.
You can have this if you are trying to manifest your application that it has a dependancy on the Microsoft.Windows.Common-Controls assembly. You do this when you want to load Version 6 of the common controls library - so that visual styles are applied to common controls.
You probably followed Microsoft's original documentation way back from Windows XP days, and added the following to your application's manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Windows XP is no longer the OS, and you're no longer a 32-bit application. In the intervening 17 years Microsoft updated their documentation; now it's time for you to update your manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Raymond Chen has a lovely history of the Common Controls:
The history of the Windows XP common controls (archive)
The main problem, of course, is that a DLL file is missing, or, even more likely, corrupt. If this is the case, then I have some pretty good ideas (especially if you've downloaded and installed a DLL manually!)...
TLDR: Delete every manually copy/pasted DLL you've done, uninstall old redistributable installs, and reinstall new redistributables for both 32-bit and 64-bit installs.
What To Do
This solution of copying/pasting missing DLL's into system32, etc., used to work since I can remember in the 1990's, but it doesn't seem to work anymore (2020). So if you run into this problem recently, I suggest:
Within windows\system32 and windows\SysWOW64, delete all files that match ms*.dll, that the operating system will allow you delete as admin.
Uninstall all Visual C++ Redistributables that you have with Windows. This prevents the "You already have this!" dialogue showing up upon reinstall, as detailed in the next step when we re-install.
Reinstall the 2015-2019 Visual C++ Redistributable from a regularly available download site. If this does not work, download and install the others, but personally, the 2015-2019 covered everything for me. Regardless of your machine, install both x32 and x64 packages! (All Download Links: Collected VC++ Download Links; MSVCR120.dll Fix; MFC140U.dll Fix.)
How You Know It's Working
There's a lot of variation in coders experiencing this, so, the idea that there's one single, possible solution is often discarded, but let's be positive!
If deleting the matching ms*.dll files worked, then you will no longer get an error about error code 0xc000007b. Instead, you'll get a message about a missing .dll. This tells you that you're hitting the right code path!
If installing the redistributable works, then certain popular, DLL files should appear in the above-mentioned system32 and SysWO64 folders. For instance: MSVCR120.dll, MSVCR140.dll, MSVCR100.dll, MSVCP100.dll, MSVCP120.dll, MSVCP140.dll, and friends.
Last, Possible Best Chances
Sometimes things don't work according to plan (as we all in the Windows world know). You can also try the following!
Open the "Turn Windows Features on or off" tab in Windows (supported in Windows 8-10). Uncheck the .NET Framework installations. You'll see a small installation go by.
Restart the system. Go to the above feature again, recheck .NET Framework, and click "okay". If this works, you'll see a "installing and updating .NET framework" message that takes maybe a minute or so to go by. Once this is done, I recommend a reboot again.
Good luck!
Just solved this problem for my personal project (thanks to Dries for that). For me it was because the project path was too long. After saving the .sln to a shorter path (C:/MyProjects) and compiling from there it ran without the error.
Also download and unzip "Dependencies" into same folder where you put the wget.exe from
http://gnuwin32.sourceforge.net/packages/wget.htm
You will then have some lib*.dll files as well as wget.exe in the same folder and it should work fine.
(I also answered here https://superuser.com/a/873531/146668 which I originally found.)
I just ran into this issue. I searched for "C++" under my "Apps & Features" in Windows 10 control panel and noticed that some kind of update had just run a few days prior and installed VC++ Redistributable 2012-2017. The app that was running into the error message only required VC++ 2010. I uninstalled all of them and then reinstalled just 2010 x86/x64, and the error went away and the application functioned as expected.
That can happen if for some reason a x86 resource is loaded from a x64 machine. To avoid that explicitly, add this preprocessor directive to stdafx.h (of course, in my example the problematic resource is Windows Common Controls DLL.
#if defined(_WIN64)
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df'\"")
#endif
It is possible that you have multiple versions of the dll(s) on your system. You can search your system to find out. The issue may be solved by simply changing the order of the directories in your path. This was my issue. (Cannot run Qt Creator GUI outside of Qt. "The application was unable to start correctly (0xc000007b)" error)
I ran into this issue when fetching code from my repository and compiling on a new machine. Copying over the entire repository and then compiling resulted in an executable which worked. Turns out a 32bit DLL accidentally wasn't checked in. As the people above state, use "Dependency Walker" to figure out where it goes wrong.
To make it more clear what to look for see the below screenshot, with in the background the exe trying to load the wrong DLL (notice the '64') resulting in "the application was unable to start correctly 0xc00007b" and in the foreground the exe which was simply copied over (which included the correct DLL).
I came here when I was searching for: "golang Windows (0xc00007b)"
I have an app written in Golang, which uses iconv. It worked on my machine, but not in someone else's machine.
The first error was the missing DLL: libiconv-2.dll, so I guess they downloaded it on the internet but it was the 32 bit and not 64 bit version, so the 0xc00007b error appeared.
I searched the DLL on my system but I did not have success until I searched on MinGW 64 path which in my case is: C:\msys64\mingw64\bin
The solution was to distribute the DLL with the .exe, which was in the MinGW folder.

Using CLion to develop SDL2 programs, worked well in the IDE but got 0xc000007b error when opening it in the cmd/file explorer [duplicate]

I have a client/server app which I have been developing on a single PC. Now it needs two serial ports, so I borrowed a PC from a friend.
When I build my app and try to run or debug it (whether in the Delphi IDE or from Windows File manager), it errors "The application was unable to start correctly (0xc000007b)".
Googling doesn't bring up much, but seems to indicate that this is nothing Delphi specific and happens with other apps. It seems to be caused by calling into a 32 bit DLL from a 64 bit app or vice versa.
both PCs are Windows 7, 64 bit
both have Delphi Xe2 starter edition which can only handle 32 bits
The app runs fine on my PC, but not on my friend's
Other Delphi apps run just fine on both PCs
Can anyone give me a hint as to how to track this down?
Normally we get the 0xC000007B error-code (which means STATUS_INVALID_IMAGE_FORMAT), if:
If a 32-bit app tried to load a 64-bit DLL.
Or if a 64-bit app tried to load a 32-bit DLL.
Or if a 64-bit app tried to run on a 32-bit Windows.
To really know, I would suggest to test whether there is a problem between your application and its dependencies using dependency walker
Note that all you need to do is open your App using said tool, and issues appear as red log-entries at buttom of screen.
(At least, at time of writting, namely 2022)
Also, make sure you run the correct version of Dependency Walker, for example, the x86 version will display incorrect results when openning x64 binaries.
A load time dependency could not be resolved. The easiest way to debug this is to use Dependency Walker. Use the Profile option to get diagnostics output of the load process. This will identify the point of failure and should guide you to a solution.
The most common cause of this error is trying to load a 64 bit DLL into a 32 bit process, or vice versa.
I tried all the things specified here and found yet another answer. I had to compile my application with 32-bit DLLs. I had built the libraries both in 32-bit and 64-bit but had my PATH set to 64-bit libraries. After I recompiled my application (with a number of changes in my code as well) I got this dreaded error and struggled for two days. Finally, after trying a number of other things, I changed my PATH to have the 32-bit DLLs before the 64-bit DLLs (they have the same names). And it worked. I am just adding it here for completeness.
It is a missing dll.
Possibly, your dll that works with com ports have an unresolved dll dependence.
You can use dependency walker and windows debugger. Check all of the mfc library, for example. Also, you can use nrCommlib - it is great components to work with com ports.
It has been mentioned in earlier answers that using dependency walker is the way to go, in my case (my application keeps failing with the error code), dependency walker showed a few dll that are NOT relevant!
Finally figured out that I can run profiling by going to "profile" menu and it will run the application and stop at the exact dll that's cause the problem! I found out a 32bit dll was picked because of path and fixed it.
I experienced the same problem developing a client-server app using Microsoft Visual Studio 2012.
If you used Visual Studio to develop the app, you must make sure the new (i.e. the computer that the software was not developed on) has the appropriate Microsoft Visual C++ Redistributable Package. By appropriate, you need the right year and bit version (i.e. x86 for 32 bit and x64 for 64 bit) of the Visual C++ Redistributable Package.
The Visual C++ Redistributable Packages install run-time components that are required to run C++ applications built using Visual Studio.
Here is a link to the Visual C++ Redistributable for Visual Studio 2015 .
You can check what versions are installed by going to Control Panel -> Programs -> Programs and Features.
Here's how I got this error and fixed it:
1) I developed a 32 bit application using Visual Studio 2012 on my computer.
Let's call my computer ComputerA.
2) I installed the .exe and the related files on a different computer we'll call ComputerB.
3) On ComputerB, I ran the .exe and got the error message.
4) On ComputerB, I looked at the Programs and Features and didn't see Visual C++ 2012 Redistributable (x64).
5) On ComputerB, I googled for Visual C++ 2012 Redistributable and selected and installed the x64 version.
6) On ComputerB, I ran the .exe on ComputerB and did not receive the error message.
I recently had an issue where I was developing an application (that used a serial port) and it worked on all the machines I tested it on but a few people were getting this error.
It turns out all the machines that the error happened on were running Win7 x64 and had NEVER ONCE been updated.
Running a Windows update fixed all of the machines in my particular case.
Actually this error indicates to an invalid image format. However, why this is happening and what the error code usually means? Actually this could be appear when you are trying to run a program that is made for or intended to work with a 64 bit Windows operating system, but your computer is running on 32 bit Operating system.
Possible Reasons:
Microsoft Visual C++
Need to restart
DirectX
.NET Framework
Need to Re-Install
Need to Run the application as an administrator
Source: http://www.solveinweb.com/solved-the-application-was-unable-to-start-correctly-0xc000007b-click-ok-to-close-the-application/
This may be a case where debugging the debugger might be useful. Essentially if you follow the instructions here you can run two ide's and one will debug into the other. If you un your application in one, you can sometimes catch errors that you otherwise miss. Its worth a try.
I have seen the error trying to run VC++ debug executable on a machine which did not have Visual C++ installed. Building a release version and using that fixed it.
In my case the error occurred when I renamed a DLL after building it (using Visual Studio 2015), so that it fits the name expected by an executable, which depended on the DLL. After the renaming the list of exported symbols displayed by Dependency Walker was empty, and the said error message "The application was unable to start correctly" was displayed.
So it could be fixed by changing the output file name in the Visual Studio linker options.
You can have this if you are trying to manifest your application that it has a dependancy on the Microsoft.Windows.Common-Controls assembly. You do this when you want to load Version 6 of the common controls library - so that visual styles are applied to common controls.
You probably followed Microsoft's original documentation way back from Windows XP days, and added the following to your application's manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Windows XP is no longer the OS, and you're no longer a 32-bit application. In the intervening 17 years Microsoft updated their documentation; now it's time for you to update your manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Raymond Chen has a lovely history of the Common Controls:
The history of the Windows XP common controls (archive)
The main problem, of course, is that a DLL file is missing, or, even more likely, corrupt. If this is the case, then I have some pretty good ideas (especially if you've downloaded and installed a DLL manually!)...
TLDR: Delete every manually copy/pasted DLL you've done, uninstall old redistributable installs, and reinstall new redistributables for both 32-bit and 64-bit installs.
What To Do
This solution of copying/pasting missing DLL's into system32, etc., used to work since I can remember in the 1990's, but it doesn't seem to work anymore (2020). So if you run into this problem recently, I suggest:
Within windows\system32 and windows\SysWOW64, delete all files that match ms*.dll, that the operating system will allow you delete as admin.
Uninstall all Visual C++ Redistributables that you have with Windows. This prevents the "You already have this!" dialogue showing up upon reinstall, as detailed in the next step when we re-install.
Reinstall the 2015-2019 Visual C++ Redistributable from a regularly available download site. If this does not work, download and install the others, but personally, the 2015-2019 covered everything for me. Regardless of your machine, install both x32 and x64 packages! (All Download Links: Collected VC++ Download Links; MSVCR120.dll Fix; MFC140U.dll Fix.)
How You Know It's Working
There's a lot of variation in coders experiencing this, so, the idea that there's one single, possible solution is often discarded, but let's be positive!
If deleting the matching ms*.dll files worked, then you will no longer get an error about error code 0xc000007b. Instead, you'll get a message about a missing .dll. This tells you that you're hitting the right code path!
If installing the redistributable works, then certain popular, DLL files should appear in the above-mentioned system32 and SysWO64 folders. For instance: MSVCR120.dll, MSVCR140.dll, MSVCR100.dll, MSVCP100.dll, MSVCP120.dll, MSVCP140.dll, and friends.
Last, Possible Best Chances
Sometimes things don't work according to plan (as we all in the Windows world know). You can also try the following!
Open the "Turn Windows Features on or off" tab in Windows (supported in Windows 8-10). Uncheck the .NET Framework installations. You'll see a small installation go by.
Restart the system. Go to the above feature again, recheck .NET Framework, and click "okay". If this works, you'll see a "installing and updating .NET framework" message that takes maybe a minute or so to go by. Once this is done, I recommend a reboot again.
Good luck!
Just solved this problem for my personal project (thanks to Dries for that). For me it was because the project path was too long. After saving the .sln to a shorter path (C:/MyProjects) and compiling from there it ran without the error.
Also download and unzip "Dependencies" into same folder where you put the wget.exe from
http://gnuwin32.sourceforge.net/packages/wget.htm
You will then have some lib*.dll files as well as wget.exe in the same folder and it should work fine.
(I also answered here https://superuser.com/a/873531/146668 which I originally found.)
I just ran into this issue. I searched for "C++" under my "Apps & Features" in Windows 10 control panel and noticed that some kind of update had just run a few days prior and installed VC++ Redistributable 2012-2017. The app that was running into the error message only required VC++ 2010. I uninstalled all of them and then reinstalled just 2010 x86/x64, and the error went away and the application functioned as expected.
That can happen if for some reason a x86 resource is loaded from a x64 machine. To avoid that explicitly, add this preprocessor directive to stdafx.h (of course, in my example the problematic resource is Windows Common Controls DLL.
#if defined(_WIN64)
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df'\"")
#endif
It is possible that you have multiple versions of the dll(s) on your system. You can search your system to find out. The issue may be solved by simply changing the order of the directories in your path. This was my issue. (Cannot run Qt Creator GUI outside of Qt. "The application was unable to start correctly (0xc000007b)" error)
I ran into this issue when fetching code from my repository and compiling on a new machine. Copying over the entire repository and then compiling resulted in an executable which worked. Turns out a 32bit DLL accidentally wasn't checked in. As the people above state, use "Dependency Walker" to figure out where it goes wrong.
To make it more clear what to look for see the below screenshot, with in the background the exe trying to load the wrong DLL (notice the '64') resulting in "the application was unable to start correctly 0xc00007b" and in the foreground the exe which was simply copied over (which included the correct DLL).
I came here when I was searching for: "golang Windows (0xc00007b)"
I have an app written in Golang, which uses iconv. It worked on my machine, but not in someone else's machine.
The first error was the missing DLL: libiconv-2.dll, so I guess they downloaded it on the internet but it was the 32 bit and not 64 bit version, so the 0xc00007b error appeared.
I searched the DLL on my system but I did not have success until I searched on MinGW 64 path which in my case is: C:\msys64\mingw64\bin
The solution was to distribute the DLL with the .exe, which was in the MinGW folder.

Getting Error "The application was unable to start correctly (0xc000007b)" when trying to run a Qt application on Windows server 2012 [duplicate]

I have a client/server app which I have been developing on a single PC. Now it needs two serial ports, so I borrowed a PC from a friend.
When I build my app and try to run or debug it (whether in the Delphi IDE or from Windows File manager), it errors "The application was unable to start correctly (0xc000007b)".
Googling doesn't bring up much, but seems to indicate that this is nothing Delphi specific and happens with other apps. It seems to be caused by calling into a 32 bit DLL from a 64 bit app or vice versa.
both PCs are Windows 7, 64 bit
both have Delphi Xe2 starter edition which can only handle 32 bits
The app runs fine on my PC, but not on my friend's
Other Delphi apps run just fine on both PCs
Can anyone give me a hint as to how to track this down?
Normally we get the 0xC000007B error-code (which means STATUS_INVALID_IMAGE_FORMAT), if:
If a 32-bit app tried to load a 64-bit DLL.
Or if a 64-bit app tried to load a 32-bit DLL.
Or if a 64-bit app tried to run on a 32-bit Windows.
To really know, I would suggest to test whether there is a problem between your application and its dependencies using dependency walker
Note that all you need to do is open your App using said tool, and issues appear as red log-entries at buttom of screen.
(At least, at time of writting, namely 2022)
Also, make sure you run the correct version of Dependency Walker, for example, the x86 version will display incorrect results when openning x64 binaries.
A load time dependency could not be resolved. The easiest way to debug this is to use Dependency Walker. Use the Profile option to get diagnostics output of the load process. This will identify the point of failure and should guide you to a solution.
The most common cause of this error is trying to load a 64 bit DLL into a 32 bit process, or vice versa.
I tried all the things specified here and found yet another answer. I had to compile my application with 32-bit DLLs. I had built the libraries both in 32-bit and 64-bit but had my PATH set to 64-bit libraries. After I recompiled my application (with a number of changes in my code as well) I got this dreaded error and struggled for two days. Finally, after trying a number of other things, I changed my PATH to have the 32-bit DLLs before the 64-bit DLLs (they have the same names). And it worked. I am just adding it here for completeness.
It is a missing dll.
Possibly, your dll that works with com ports have an unresolved dll dependence.
You can use dependency walker and windows debugger. Check all of the mfc library, for example. Also, you can use nrCommlib - it is great components to work with com ports.
It has been mentioned in earlier answers that using dependency walker is the way to go, in my case (my application keeps failing with the error code), dependency walker showed a few dll that are NOT relevant!
Finally figured out that I can run profiling by going to "profile" menu and it will run the application and stop at the exact dll that's cause the problem! I found out a 32bit dll was picked because of path and fixed it.
I experienced the same problem developing a client-server app using Microsoft Visual Studio 2012.
If you used Visual Studio to develop the app, you must make sure the new (i.e. the computer that the software was not developed on) has the appropriate Microsoft Visual C++ Redistributable Package. By appropriate, you need the right year and bit version (i.e. x86 for 32 bit and x64 for 64 bit) of the Visual C++ Redistributable Package.
The Visual C++ Redistributable Packages install run-time components that are required to run C++ applications built using Visual Studio.
Here is a link to the Visual C++ Redistributable for Visual Studio 2015 .
You can check what versions are installed by going to Control Panel -> Programs -> Programs and Features.
Here's how I got this error and fixed it:
1) I developed a 32 bit application using Visual Studio 2012 on my computer.
Let's call my computer ComputerA.
2) I installed the .exe and the related files on a different computer we'll call ComputerB.
3) On ComputerB, I ran the .exe and got the error message.
4) On ComputerB, I looked at the Programs and Features and didn't see Visual C++ 2012 Redistributable (x64).
5) On ComputerB, I googled for Visual C++ 2012 Redistributable and selected and installed the x64 version.
6) On ComputerB, I ran the .exe on ComputerB and did not receive the error message.
I recently had an issue where I was developing an application (that used a serial port) and it worked on all the machines I tested it on but a few people were getting this error.
It turns out all the machines that the error happened on were running Win7 x64 and had NEVER ONCE been updated.
Running a Windows update fixed all of the machines in my particular case.
Actually this error indicates to an invalid image format. However, why this is happening and what the error code usually means? Actually this could be appear when you are trying to run a program that is made for or intended to work with a 64 bit Windows operating system, but your computer is running on 32 bit Operating system.
Possible Reasons:
Microsoft Visual C++
Need to restart
DirectX
.NET Framework
Need to Re-Install
Need to Run the application as an administrator
Source: http://www.solveinweb.com/solved-the-application-was-unable-to-start-correctly-0xc000007b-click-ok-to-close-the-application/
This may be a case where debugging the debugger might be useful. Essentially if you follow the instructions here you can run two ide's and one will debug into the other. If you un your application in one, you can sometimes catch errors that you otherwise miss. Its worth a try.
I have seen the error trying to run VC++ debug executable on a machine which did not have Visual C++ installed. Building a release version and using that fixed it.
In my case the error occurred when I renamed a DLL after building it (using Visual Studio 2015), so that it fits the name expected by an executable, which depended on the DLL. After the renaming the list of exported symbols displayed by Dependency Walker was empty, and the said error message "The application was unable to start correctly" was displayed.
So it could be fixed by changing the output file name in the Visual Studio linker options.
You can have this if you are trying to manifest your application that it has a dependancy on the Microsoft.Windows.Common-Controls assembly. You do this when you want to load Version 6 of the common controls library - so that visual styles are applied to common controls.
You probably followed Microsoft's original documentation way back from Windows XP days, and added the following to your application's manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Windows XP is no longer the OS, and you're no longer a 32-bit application. In the intervening 17 years Microsoft updated their documentation; now it's time for you to update your manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Raymond Chen has a lovely history of the Common Controls:
The history of the Windows XP common controls (archive)
The main problem, of course, is that a DLL file is missing, or, even more likely, corrupt. If this is the case, then I have some pretty good ideas (especially if you've downloaded and installed a DLL manually!)...
TLDR: Delete every manually copy/pasted DLL you've done, uninstall old redistributable installs, and reinstall new redistributables for both 32-bit and 64-bit installs.
What To Do
This solution of copying/pasting missing DLL's into system32, etc., used to work since I can remember in the 1990's, but it doesn't seem to work anymore (2020). So if you run into this problem recently, I suggest:
Within windows\system32 and windows\SysWOW64, delete all files that match ms*.dll, that the operating system will allow you delete as admin.
Uninstall all Visual C++ Redistributables that you have with Windows. This prevents the "You already have this!" dialogue showing up upon reinstall, as detailed in the next step when we re-install.
Reinstall the 2015-2019 Visual C++ Redistributable from a regularly available download site. If this does not work, download and install the others, but personally, the 2015-2019 covered everything for me. Regardless of your machine, install both x32 and x64 packages! (All Download Links: Collected VC++ Download Links; MSVCR120.dll Fix; MFC140U.dll Fix.)
How You Know It's Working
There's a lot of variation in coders experiencing this, so, the idea that there's one single, possible solution is often discarded, but let's be positive!
If deleting the matching ms*.dll files worked, then you will no longer get an error about error code 0xc000007b. Instead, you'll get a message about a missing .dll. This tells you that you're hitting the right code path!
If installing the redistributable works, then certain popular, DLL files should appear in the above-mentioned system32 and SysWO64 folders. For instance: MSVCR120.dll, MSVCR140.dll, MSVCR100.dll, MSVCP100.dll, MSVCP120.dll, MSVCP140.dll, and friends.
Last, Possible Best Chances
Sometimes things don't work according to plan (as we all in the Windows world know). You can also try the following!
Open the "Turn Windows Features on or off" tab in Windows (supported in Windows 8-10). Uncheck the .NET Framework installations. You'll see a small installation go by.
Restart the system. Go to the above feature again, recheck .NET Framework, and click "okay". If this works, you'll see a "installing and updating .NET framework" message that takes maybe a minute or so to go by. Once this is done, I recommend a reboot again.
Good luck!
Just solved this problem for my personal project (thanks to Dries for that). For me it was because the project path was too long. After saving the .sln to a shorter path (C:/MyProjects) and compiling from there it ran without the error.
Also download and unzip "Dependencies" into same folder where you put the wget.exe from
http://gnuwin32.sourceforge.net/packages/wget.htm
You will then have some lib*.dll files as well as wget.exe in the same folder and it should work fine.
(I also answered here https://superuser.com/a/873531/146668 which I originally found.)
I just ran into this issue. I searched for "C++" under my "Apps & Features" in Windows 10 control panel and noticed that some kind of update had just run a few days prior and installed VC++ Redistributable 2012-2017. The app that was running into the error message only required VC++ 2010. I uninstalled all of them and then reinstalled just 2010 x86/x64, and the error went away and the application functioned as expected.
That can happen if for some reason a x86 resource is loaded from a x64 machine. To avoid that explicitly, add this preprocessor directive to stdafx.h (of course, in my example the problematic resource is Windows Common Controls DLL.
#if defined(_WIN64)
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df'\"")
#endif
It is possible that you have multiple versions of the dll(s) on your system. You can search your system to find out. The issue may be solved by simply changing the order of the directories in your path. This was my issue. (Cannot run Qt Creator GUI outside of Qt. "The application was unable to start correctly (0xc000007b)" error)
I ran into this issue when fetching code from my repository and compiling on a new machine. Copying over the entire repository and then compiling resulted in an executable which worked. Turns out a 32bit DLL accidentally wasn't checked in. As the people above state, use "Dependency Walker" to figure out where it goes wrong.
To make it more clear what to look for see the below screenshot, with in the background the exe trying to load the wrong DLL (notice the '64') resulting in "the application was unable to start correctly 0xc00007b" and in the foreground the exe which was simply copied over (which included the correct DLL).
I came here when I was searching for: "golang Windows (0xc00007b)"
I have an app written in Golang, which uses iconv. It worked on my machine, but not in someone else's machine.
The first error was the missing DLL: libiconv-2.dll, so I guess they downloaded it on the internet but it was the 32 bit and not 64 bit version, so the 0xc00007b error appeared.
I searched the DLL on my system but I did not have success until I searched on MinGW 64 path which in my case is: C:\msys64\mingw64\bin
The solution was to distribute the DLL with the .exe, which was in the MinGW folder.

Assimp and visual studio: error 0xc000007b [duplicate]

I have a client/server app which I have been developing on a single PC. Now it needs two serial ports, so I borrowed a PC from a friend.
When I build my app and try to run or debug it (whether in the Delphi IDE or from Windows File manager), it errors "The application was unable to start correctly (0xc000007b)".
Googling doesn't bring up much, but seems to indicate that this is nothing Delphi specific and happens with other apps. It seems to be caused by calling into a 32 bit DLL from a 64 bit app or vice versa.
both PCs are Windows 7, 64 bit
both have Delphi Xe2 starter edition which can only handle 32 bits
The app runs fine on my PC, but not on my friend's
Other Delphi apps run just fine on both PCs
Can anyone give me a hint as to how to track this down?
Normally we get the 0xC000007B error-code (which means STATUS_INVALID_IMAGE_FORMAT), if:
If a 32-bit app tried to load a 64-bit DLL.
Or if a 64-bit app tried to load a 32-bit DLL.
Or if a 64-bit app tried to run on a 32-bit Windows.
To really know, I would suggest to test whether there is a problem between your application and its dependencies using dependency walker
Note that all you need to do is open your App using said tool, and issues appear as red log-entries at buttom of screen.
(At least, at time of writting, namely 2022)
Also, make sure you run the correct version of Dependency Walker, for example, the x86 version will display incorrect results when openning x64 binaries.
A load time dependency could not be resolved. The easiest way to debug this is to use Dependency Walker. Use the Profile option to get diagnostics output of the load process. This will identify the point of failure and should guide you to a solution.
The most common cause of this error is trying to load a 64 bit DLL into a 32 bit process, or vice versa.
I tried all the things specified here and found yet another answer. I had to compile my application with 32-bit DLLs. I had built the libraries both in 32-bit and 64-bit but had my PATH set to 64-bit libraries. After I recompiled my application (with a number of changes in my code as well) I got this dreaded error and struggled for two days. Finally, after trying a number of other things, I changed my PATH to have the 32-bit DLLs before the 64-bit DLLs (they have the same names). And it worked. I am just adding it here for completeness.
It is a missing dll.
Possibly, your dll that works with com ports have an unresolved dll dependence.
You can use dependency walker and windows debugger. Check all of the mfc library, for example. Also, you can use nrCommlib - it is great components to work with com ports.
It has been mentioned in earlier answers that using dependency walker is the way to go, in my case (my application keeps failing with the error code), dependency walker showed a few dll that are NOT relevant!
Finally figured out that I can run profiling by going to "profile" menu and it will run the application and stop at the exact dll that's cause the problem! I found out a 32bit dll was picked because of path and fixed it.
I experienced the same problem developing a client-server app using Microsoft Visual Studio 2012.
If you used Visual Studio to develop the app, you must make sure the new (i.e. the computer that the software was not developed on) has the appropriate Microsoft Visual C++ Redistributable Package. By appropriate, you need the right year and bit version (i.e. x86 for 32 bit and x64 for 64 bit) of the Visual C++ Redistributable Package.
The Visual C++ Redistributable Packages install run-time components that are required to run C++ applications built using Visual Studio.
Here is a link to the Visual C++ Redistributable for Visual Studio 2015 .
You can check what versions are installed by going to Control Panel -> Programs -> Programs and Features.
Here's how I got this error and fixed it:
1) I developed a 32 bit application using Visual Studio 2012 on my computer.
Let's call my computer ComputerA.
2) I installed the .exe and the related files on a different computer we'll call ComputerB.
3) On ComputerB, I ran the .exe and got the error message.
4) On ComputerB, I looked at the Programs and Features and didn't see Visual C++ 2012 Redistributable (x64).
5) On ComputerB, I googled for Visual C++ 2012 Redistributable and selected and installed the x64 version.
6) On ComputerB, I ran the .exe on ComputerB and did not receive the error message.
I recently had an issue where I was developing an application (that used a serial port) and it worked on all the machines I tested it on but a few people were getting this error.
It turns out all the machines that the error happened on were running Win7 x64 and had NEVER ONCE been updated.
Running a Windows update fixed all of the machines in my particular case.
Actually this error indicates to an invalid image format. However, why this is happening and what the error code usually means? Actually this could be appear when you are trying to run a program that is made for or intended to work with a 64 bit Windows operating system, but your computer is running on 32 bit Operating system.
Possible Reasons:
Microsoft Visual C++
Need to restart
DirectX
.NET Framework
Need to Re-Install
Need to Run the application as an administrator
Source: http://www.solveinweb.com/solved-the-application-was-unable-to-start-correctly-0xc000007b-click-ok-to-close-the-application/
This may be a case where debugging the debugger might be useful. Essentially if you follow the instructions here you can run two ide's and one will debug into the other. If you un your application in one, you can sometimes catch errors that you otherwise miss. Its worth a try.
I have seen the error trying to run VC++ debug executable on a machine which did not have Visual C++ installed. Building a release version and using that fixed it.
In my case the error occurred when I renamed a DLL after building it (using Visual Studio 2015), so that it fits the name expected by an executable, which depended on the DLL. After the renaming the list of exported symbols displayed by Dependency Walker was empty, and the said error message "The application was unable to start correctly" was displayed.
So it could be fixed by changing the output file name in the Visual Studio linker options.
You can have this if you are trying to manifest your application that it has a dependancy on the Microsoft.Windows.Common-Controls assembly. You do this when you want to load Version 6 of the common controls library - so that visual styles are applied to common controls.
You probably followed Microsoft's original documentation way back from Windows XP days, and added the following to your application's manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Windows XP is no longer the OS, and you're no longer a 32-bit application. In the intervening 17 years Microsoft updated their documentation; now it's time for you to update your manifest:
<!-- Dependancy on Common Controls version 6 -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"/>
</dependentAssembly>
</dependency>
Raymond Chen has a lovely history of the Common Controls:
The history of the Windows XP common controls (archive)
The main problem, of course, is that a DLL file is missing, or, even more likely, corrupt. If this is the case, then I have some pretty good ideas (especially if you've downloaded and installed a DLL manually!)...
TLDR: Delete every manually copy/pasted DLL you've done, uninstall old redistributable installs, and reinstall new redistributables for both 32-bit and 64-bit installs.
What To Do
This solution of copying/pasting missing DLL's into system32, etc., used to work since I can remember in the 1990's, but it doesn't seem to work anymore (2020). So if you run into this problem recently, I suggest:
Within windows\system32 and windows\SysWOW64, delete all files that match ms*.dll, that the operating system will allow you delete as admin.
Uninstall all Visual C++ Redistributables that you have with Windows. This prevents the "You already have this!" dialogue showing up upon reinstall, as detailed in the next step when we re-install.
Reinstall the 2015-2019 Visual C++ Redistributable from a regularly available download site. If this does not work, download and install the others, but personally, the 2015-2019 covered everything for me. Regardless of your machine, install both x32 and x64 packages! (All Download Links: Collected VC++ Download Links; MSVCR120.dll Fix; MFC140U.dll Fix.)
How You Know It's Working
There's a lot of variation in coders experiencing this, so, the idea that there's one single, possible solution is often discarded, but let's be positive!
If deleting the matching ms*.dll files worked, then you will no longer get an error about error code 0xc000007b. Instead, you'll get a message about a missing .dll. This tells you that you're hitting the right code path!
If installing the redistributable works, then certain popular, DLL files should appear in the above-mentioned system32 and SysWO64 folders. For instance: MSVCR120.dll, MSVCR140.dll, MSVCR100.dll, MSVCP100.dll, MSVCP120.dll, MSVCP140.dll, and friends.
Last, Possible Best Chances
Sometimes things don't work according to plan (as we all in the Windows world know). You can also try the following!
Open the "Turn Windows Features on or off" tab in Windows (supported in Windows 8-10). Uncheck the .NET Framework installations. You'll see a small installation go by.
Restart the system. Go to the above feature again, recheck .NET Framework, and click "okay". If this works, you'll see a "installing and updating .NET framework" message that takes maybe a minute or so to go by. Once this is done, I recommend a reboot again.
Good luck!
Just solved this problem for my personal project (thanks to Dries for that). For me it was because the project path was too long. After saving the .sln to a shorter path (C:/MyProjects) and compiling from there it ran without the error.
Also download and unzip "Dependencies" into same folder where you put the wget.exe from
http://gnuwin32.sourceforge.net/packages/wget.htm
You will then have some lib*.dll files as well as wget.exe in the same folder and it should work fine.
(I also answered here https://superuser.com/a/873531/146668 which I originally found.)
I just ran into this issue. I searched for "C++" under my "Apps & Features" in Windows 10 control panel and noticed that some kind of update had just run a few days prior and installed VC++ Redistributable 2012-2017. The app that was running into the error message only required VC++ 2010. I uninstalled all of them and then reinstalled just 2010 x86/x64, and the error went away and the application functioned as expected.
That can happen if for some reason a x86 resource is loaded from a x64 machine. To avoid that explicitly, add this preprocessor directive to stdafx.h (of course, in my example the problematic resource is Windows Common Controls DLL.
#if defined(_WIN64)
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df'\"")
#endif
It is possible that you have multiple versions of the dll(s) on your system. You can search your system to find out. The issue may be solved by simply changing the order of the directories in your path. This was my issue. (Cannot run Qt Creator GUI outside of Qt. "The application was unable to start correctly (0xc000007b)" error)
I ran into this issue when fetching code from my repository and compiling on a new machine. Copying over the entire repository and then compiling resulted in an executable which worked. Turns out a 32bit DLL accidentally wasn't checked in. As the people above state, use "Dependency Walker" to figure out where it goes wrong.
To make it more clear what to look for see the below screenshot, with in the background the exe trying to load the wrong DLL (notice the '64') resulting in "the application was unable to start correctly 0xc00007b" and in the foreground the exe which was simply copied over (which included the correct DLL).
I came here when I was searching for: "golang Windows (0xc00007b)"
I have an app written in Golang, which uses iconv. It worked on my machine, but not in someone else's machine.
The first error was the missing DLL: libiconv-2.dll, so I guess they downloaded it on the internet but it was the 32 bit and not 64 bit version, so the 0xc00007b error appeared.
I searched the DLL on my system but I did not have success until I searched on MinGW 64 path which in my case is: C:\msys64\mingw64\bin
The solution was to distribute the DLL with the .exe, which was in the MinGW folder.

How do I make my application use the Windows theme?

I'm working with some windows API to create a little application.
I already created the buttons, windows, alright.
But the problem is the components I created don't look like the OS theme. They look very simple:
See the button as example.
How do I enable the Windows theme? It can be in C or Delphi.
For an application using windows controls, that is documented in this msdn article
Edit: To make a long story short, Windows needs to know for an application if it was intended to use the new style controls. Some older apps just aren't compatible with the new skinned looks of XP and later. Each exe should therefore declare with which version it is compatible in a manifest, an embedded xml file in the executable. The manifest is used for other things like declaring what you are or aren't compatible with (DLL versions, 120 dpi) as well as registration-free com.
It depends on what version of Delphi
you're using. IIRC pre-Delphi 6 you
need to add the needed manifest by
hand. D7 and later has a component
that need to be dropped on a form to
add theme support (it simply adds the manifest), until D2007 IIRC
added a simple check in the project
options.
Earlier version of Delphi won't show themed design form. You will see themes only at run time.
Not all controls may support themes. Themes require the proper draw API to be called, if a control doesn't comply it won't be themed. The standard grid is a good example, it isn't draw themed until a late version.
If you're using Delphi 2007 or later, Project > Options > Application > Use Windows Themes needs to be checked.
(This should be automatically checked for new applications).
In Visual Styles Reference: Functions of MSDN, I found an interesting functions, that is, SetWindowTheme(). It can be used to either to apply or remove visual style to/from a control/window, there are several steps need to be done to enable Visual Style in an application.
To use Windows Theme api, you'll need JwaUxTheme unit of JEDI API Library.
However, applying theme from Windows Theme files (.theme) to an application seems has to be done by turning off visual style from controls and write owner drawn controls based on information from .theme files. MSDN has a documentation about .theme file specification (see the first reference below).
Some good references:
Creating and Installing Theme Files
Fully themed Windows Vista Controls
Creating Windows Vista Ready Applications with Delphi
Is Windows Presentation Foundation (WPF) Themes bad? There is a code example how to load it here.
If you use VCL, Theme Engine and Skin Engine has a complete support of themes for Windows XP.
If beauty application is your priority (without supports for Windows themes), I think, BusinessSkinForm and DynamicSkinForm is the best choice.
If your executable name is YourAppName.exe then, create a manifest file named YourAppName.exe.manifest in the same directory where the executable application is.
YourAppName.exe.manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
name="YourAppName"
processorArchitecture="*"
version="1.0.0.0"
type="win32"/>
<description>MyApp</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
For embedding manifest file into executable use mt.exe
commandline syntax:
mt.exe –manifest YourAppName.exe.manifest -outputresource:YourAppName.exe;1