I want to automatically add loaded dll of the current application into ironruby engine so that each time I execute a script I won't specify the "require" script anymore.
Thanks a lot.
I did this in September 2008 using ScriptRuntime.LoadAssembly. Here's my original code
// this part may have changed, there's probably a different
// way to get the ScriptRuntime from the RubyEngine or somesuch
var runtime = new ScriptRuntime( Ruby.CreateRuntimeSetup() );
// give ruby access to all our assemblies
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
runtime.LoadAssembly(assembly);
}
You can use IronRuby.Ruby.RequireFile in order to load a script file only once.
For example, the next line loads the CSV library from the standard library folder:
IronRuby.Ruby.RequireFile(engine, #"D:\IronRuby\lib\ruby\1.8\csv.rb");
Hope it helps,
Shay.
Related
We have an old OCX, that used in old VB application.
Both of them do not support by developer now. and source code also not available.
OCX contains a function which calculate a value and now we have to change the formula of calculation.
Is there any way to override method and create a news ocx with same functionality?
Edit: ocx contain a date picker which using mscomctl2.ocx, our formula is based on selected date, so if we can find a solution to change date after selection, we can reach to our need.
There is another way, Safe to use only if you are owner of that ocx file. You can use vb decompiler to get source code from your ocx file so you can modify and create new source code. Here is a decompiler
http://www.vb-decompiler.org/
You can decompile OCX, use hooks, patch memory or completely rewrite it as mentioned in other comments and answers.
But first thing I'll try is make wrapper around your OCX. If your functionality replaces some functions or adds before or after, wrapper (AKA Proxy pattern) is the best choice.
Example of this method is DLLs around dx3d which uses OpenGL.
I've created Qt project using Visual studio 2012 32 bit and Qt5 SDK with the help of Visual studio Qt addon. I'm using Windows 7 ultimate OS.
I have created QApplication GUI Project which basically uses the following libraries:
qtmain.lib
Qt5Core.lib
Qt5Gui.lib
Qt5Network.lib
Ws2_32.lib
Winhttp.lib
Winmm.lib
Qt5Widgets.lib
Qt5PlatformSupport.lib
imm32.lib
And I have succeed in building the application binary without any errors.
I’m trying to run this application on test machine windows 7 desktop having following dlls copied there:
icudt51.dll
icuin51.dll
icuuc51.dll
libEGL.dll
libGLESv2.dll
Qt5Core.dll
Qt5Network.dll
Qt5GUI.dll
Qt5Widgets.dll
qwindows.dll [copied from msvc2012\plugins\platform folder ]
I’m getting the error:
Failed to load platform plugin “windows”. Available Platform are : while trying to run the application.
What would i have missed? How to make it run on windows platform? Please Help me to troubleshoot this.
I've followed the links posted about this problem previously. but none of them are solved my problem. What configuration I am missing?
The platform plugin dlls would need to be put into the platforms subfolder and then it will work.
Yet another solution: Early in your main function or whatever, call QCoreApplication::addLibraryPath(). A simple example:
std::ifstream configurationStream("whateverNameYouWant.conf");
std::stringstream configurationText;
configurationText << configurationStream.rdbuf();
auto ct = configurationText.str();
if (!ct.empty())
QCoreApplication::addLibraryPath(QString::fromStdString(ct));
Here I load the path from a .conf file of my own invention, so that the path won't be hardcoded into my program. Since I invented this file, I control its format; in this case it contains nothing but the path. The actual path I'm using is C:/qt5/qtbase/plugins; that directory contains platforms/qwindows.dll and other such files. One may adjust the paths for one's own case according to where one's Qt files are installed.
I guess it is also supposed to be possible to use a standard qt.conf file, using a format specified by Qt, to automatically load some special paths (including this plugins path) without having to add special code to your own program for the purpose: http://doc.qt.io/qt-5/qt-conf.html ...But I haven't ever managed to get that to work, for whatever reason. Maybe I'm making some simple mistake, I dunno.
An other solution is to add arguments to the QApplication object (or to the starting application).
For instance, you want to load qwindow.dll from C:\test\platforms.dll, you can instanciate QApplication object with the following code :
int ac = 4;
static char * av[] = {"myappli.exe","C:\\\\path\\to\\myappli.exe","-platformpluginpath","C:\\\\test"};
m_qApp = new QApplication(ac, av);
Be careful, the QTCore dll can't be into the directory C:\test (loading dll conflict)
If you specify a working directory different than the one where your executable is located, no matter the plugins are there, it will fail.
So, in that case, copy your file with a post build event.
And in:
Configuration properties->Debugging->Command
specify the full path of the executable.
This was tested on VStudio 2008.
Earlier I was using gtest for my project. For the time being I am using gmock and when I have provided the path for gmock.lib, gmock_mock.lib and ..\..\include too. Then the control is not at all going into the code.
Suppose previously it was like e.g.
main()
{
printf("Hello world"); //Kept the breakpoint here, control comes here
}
Now after adding .lib and include paths it is not at all executing just strats debug and ends without going anywhere...
Please help me.
Google test lets you write unit tests using the TEST macro. It is not intended for use with normal programs that already have a main(). If you want to use google test you should create another project.
I'm trying to compile a code that uses the fmemopen function in MinGW. I found out the there is no equivalent function in MinGW. Are the any alternative functions that I can use. In case if you have written an equivalent function for fmemopen please help me out.
My requirement is that, I cannot save the content into temporary files. The data has to remain within the application. So I'm not sure if the idea of creating a temp file and reading back will workout.
Thanks,
Sathish
In a nutshell: I want to do the same thing "Dependency Walker" does.
Is there any Win32 API function which can enumerate the dependencies of a EXE and/or DLL file?
And is there any safe way to detect dependencies on ActiveX classes? (I doubt it is possible, but who knows ...)
EDIT: I'm aware of available tools which provide the same core functionality (Dependency Walker, ProcessExplorer, AQTime, ...) but I want to create my own program which dumps a text file containing the required modules.
The following commands dumps the direct dependencies of some.exe :
dumpbin /imports some.exe
It works on DLLs too.
This won't list dependencies such as plugins loaded at application launch (via LoadLibrary calls). Same for COM dependencies since they work the same way (as far as I know).
If you need to know all the DLLs used by a running program, use ProcessExplorer.
findstr -i .dll exe.exe | more | findstr -i .dll | more
rem :)
Run up the application, with Process Explorer already running and set to filter for your applications .exe name.
There is no way to detect all COM dependencies that an executable has without running it.
It seems that Dependency Walker source code itself was given by Microsoft via MSJ. Please
look at Re: [DUG]: Dependency Walker.
You need to refer some other site to download since the link given in this mail trail is not working.
Please check MSJ Source Code Updates: Since I don't have time, I have not checked whether it contains source code or only EXE foæes.
User #blue... eluded to Dependency Walker. When using Dependency Walker, after opening the file you can see the base requirements that are used. Only when executing the program and exercising all of its functions can you find all of the dynamically-loaded DLLs.
Sometimes the best thing to do if you can is ask the developer what DLLs are required. An application may only load some DLLs when absolutely needed. e.g. Loading faultrep.dll, for custom Windows Error Reporting, when it is about to crash.
You probably need to walk the executable's file structure to work this out programatically. Therefore something like the 'PE Dump' program that's mentioned here: http://msdn.microsoft.com/en-gb/magazine/cc301808.aspx would be a good starting point. The actual code that you need can be found here: http://www.wheaty.net/downloads.htm
You can write a console app to wrap this up, create a PowerShell script with it or, like I usually end up doing since I only have to do it once in a blue moon, add the following to your code for a quick check:
private static HashSet<string> ReferencedAssemblies = new HashSet<string>();
...
OutputDependencies(Assembly.GetAssembly(typeof(Program)), 0);
...
static void OutputDependencies(Assembly assembly, int indent)
{
if (assembly == null) return;
Console.WriteLine(new String(' ', indent * 4) + assembly.FullName);
if (!ReferencedAssemblies.Contains(assembly.FullName))
{
ReferencedAssemblies.Add(assembly.FullName);
foreach (var childAssembly in assembly.GetReferencedAssemblies())
{
OutputDependencies(Assembly.Load(childAssembly.FullName), indent + 1);
}
}
}