Changing the way Delphi application searches system DLLs - windows

If any dummy system DLL is placed in my application folder my application loads the dummy DLL and causes an error.
For example: create version.dll in application folder and run the application will display this error:
Testscapi: TESTSCAPI.exe - Bad Image
D:\TESTApplications\TestSCAPI\VERSION.dll is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support. Error status 0xc0000020.
OK
Actually version.dll is a system DLL that is overridden by the dummy DLL placed in the application folder.
How to avoid the Delphi application from using the dummy DLL in the application path? Mentioned version.dll is for example, it could be any system DLL...
Thanks in advance.

Related

Ensure that only system DLLs are loaded for the application

We would like to ensure that when our application is loaded, it uses only Windows system DLLs and not any DLL from the folder containing the exe file for the application. The application is a standalone executable and can be run, for an example, from Download folder, hence the reason for the restriction. Unfortunately one of DLLs is not on KnownDLLs registry setting mentioned in Microsoft documentation.
The same documentation mentioned that one can use exe manifest to control the search order, but it is not clear how to do that to restrict the search path only to system libraries.

CreateProcess vs Command Line and missing DLL

When I use CreateProcess to start an application (InDesign) that is loading my plug-in, my plugin fails to load because a DLL my plugin uses can't be loaded. The strange thing is that if I double click the application or open it from a command line, my plugin loads fine.
My application that calls CreateProcess is quite large and itself uses several DLLs some of which are also used by my plug-in. I've narrowed it to the DLL that will will not load. I set it to delay load, the plugin now loads but will not load that DLL when I call it.
I've used "Process Explorer" to check out the application's PATH to make sure it's the same as when I open it from the command line. The path to the trouble DLL is in the PATH env, this is the same for other DLLs that load fine.
I launch many different apps with and without my plugins and have never seen something like this before.
Anybody know what might be going on?
Oops...
Well, I was wrong about the env PATH, it was different depending on how the application (InDesign) was launched. It looks like QuickTime changes the PATH for my application, placing it's "Apple Application Support" folder at the top. Inside that folder is a DLL with the same name as the one I'm using, namely libxml2.dll. When I load libxml2.dll in my plugin using LoadLibrary, msvcr80.dll can't be found. Shish.
Sorry for the distraction...
Check the working path when loading the application and/or plugin. Explorer and the command prompt normally set this explicitly but another application calling CreateProcess() may not.

Why does my dll end up in AppData\Local\Temp\

I have a small SWT based java application. On installation swt-win32-*.dll is installed with my application in C:\Program Files\myapp\win32.
When I looked at my application in process explorer I noticed that the dll is loaded from:
C:\Users\[Username]\AppData\Local\Temp\swtlib-32\swt-win32-*.dll
On Windows XP it ends up in:
C:\Documents and Settings\[Username]\Local Settings\Temp\swt-win32-*.dll
Whenever I delete it from the temp folder and restart my application the dll is copied there again. The other dlls my application depends on don't show this behaviour.
Who copies the dll (my application doesn't)?
What's the reason behind it?
I don't know Java very well, but if it's inside the JAR (or any kind of archive, really), then it has to be extracted into real file before it can be loaded (because OS provides no other supported way to do it).

Where do I place GLib DLLs on a Windows machine?

I am using GLib in a Windows application. Where do I place the GLib DLLs? What is the "accepted" practice here? Do I use a shared location like C:\Windows\System32 or should I keep a local copy within my application folder?
if the dll is being used for your application specifically, include it in the installation path for your application so that users know it is an associated, needed item for your application.

How to Deploy VB6 Applications?

How to run the exe file to other system?
Using VB 6
I copied the exe file to other system, then run that exe file, it not working it showing error
“component comdlg32.ocx or one its dependencies not correctly registered a file is missing or invalid”`
Can any one help me how to avoid this error?
When deploying VB6 applications, you should create a Setup, this will manage the DLL's that the VB6 application depends on. Since it is not enough to just copy the .Exe and .Dll's. You also need to register them.
The creation of the setup is included in the VB6 environment.
You can read this http://support.microsoft.com/kb/830761 which is very comprehensive.
1: http://support.microsoft.com/kb/830761 for more information.
Or if you just want the redistributable files check this kb http://support.microsoft.com/kb/290887
Copy and register the comdlg32.ocx on other system. Link: Fix Missing Comdlg32.ocx Run time Error in Portable apps.
Create an installer for your program.
Unless you are deploying your program to really old versions of Windows (prior to XP), one nice alternative is to create an XCopy package using reg-free COM. This is fairly easy for most simple programs using Make My Manifest though it can be done by hand or using other tools if you invest in a little study.
Even then a formal installer package is usually desireable though, if nothing else to create Start Menu shortcuts and set up application workspace directories.
Keep in mind that even the PDWizard is difficult to use blindly. Packaging and deployment is a topic that requires some learning investment.
Outdated or missing comdlg32.ocx runtime library is causing this error. Here is a copy of comdlg32.ocx (~60 Kb Zip). Download the file to the Desktop and extract the comdlg32.ocx to your the Windows\System32 folder.
Note: If you already have a copy of comdlg32.ocx, backup the existing file to a different folder and delete it from System32 folder.
1. Download comdlg32.zip and save to Desktop.
2. Unzip the file using WinZip or any other utility.
3. Extract comdlg32.ocx to Windows\System32 folder.
4. Type the following command from Start, Run dialog:
regsvr32 %Systemroot%\System32\comdlg32.ocx
Typically a VB 6 app will consist of an .exe some .dll libraries and a config.ini file. The exe is the starting place and it consumes the dll's and config.ini and other resources to run => you have to have all parts in the same directory for the app to run typically called "packaging" an app. E.g. An installer simply ensures that all those files in a packaged app are placed on a users computer in an Windows application directory, and creates a shortcut launch icon so that a user can click the shortcut in the start bar and the app will run.
To "package" your app (put the dll's and exe in the same folder) you can use an Add-In called "Package and Deployment Wizard":
And here is a demo of using it: https://www.youtube.com/watch?v=XT7jaoAiKDo
You can either package and create an installer and package or just create a package:
Now if the Deployment Wizard doesnt show as an add-in on your VB6 Editor Installation, go to editor's program folder and find the tools Tools folder, i.e:
Then you should be able to find the Deployment Wizard there:
Open it to use it.

Resources