I'm writing Windows CE API compatibility wrapper for Win32. It just wraps coredll.dll calls into Win32 ones. So, I made coredll project in Visual Studio, then I did a lot of exports in .def file like here:
WaitForSingleObject #497
WaitForMultipleObjects #498
SuspendThread #499
ResumeThread #500
SetThreadContext #502
ReadProcessMemory #506
WriteProcessMemory #507
All Windows CE programs are using ordinal to call function, so I defined appropriate ordinal in .def file for each function. See the full source code here: https://github.com/feel-the-dz3n/WinCeCompatLayer
But when I try to link this library and call function from it, Windows says that ordinal 343 not found in COREDLL.DLL.
Error appears even if 343 is defined, so it seems like the problem is in using VC++ or in exports.
P.S.: My library currently uses Windows 10 functions, so it may throw some errors on another versions of Windows
dumpbin coredll.dll /exports - output
Weird, but the reason was line from exports.def below:
DSA_Clone #1853
It's related to WinAPI, so I don't really know the reason.
Related
I've working on project in vs2005, to make compact framework app to be launched under wince 6.0.
In order to do that, I created the new project for the smart device.
creation of a new sda project
then I added a reference EasyModbus.dll.
Prior to this I copied the "EasyModbus.dll" file into the folder with project. Furthermore I added some code intending to Import the methods of this DLL into this project. When typing statement "Imports EasyModbus" I was surprised on having complained about error:
Namespace or type specified in the ImportsEasyModbus doesn't contain any public member or cannot be found. Make sure the namesppace or the type is defined and contains at least one public member. Make sure the imported element doesn't use any aliases
Could anyone kindly provide any suggestions, even very general and vague on possible reasons causing of emerging the error above?
"... Prior to this I copied the "EasyModbus.dll" file into the folder with project. Furthermore I added some code intending to Import the methods of this DLL into this project. ..."
I assume EasyModBus.dll is NOT a .NET CompactFramework library. I am not sure, as you did not rpovide details about "...added some code to import methods...".
If EasyModBus.dll is a native Windows CE and processor compatible DLL, then you normally use [DLLImport("EasyModBus.dll")] and then declare the native functions wrapped in .NET code. Ie:
[DllImport( "user32.dll" )]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumWindows( EnumWindowsProc lpEnumProc, IntPtr lParam );
If you can provide the DLL, I can look at and say if it is a .NET or native one.
The Hello World application, I've created in VS2005 targeting compact framework 2.0 normally launches under emulator, also on my PC. Thus I went Build ---> Build DeviceApplication1. The application 'DeviceApplication1.exe' was built. Then I copied it on SD card of target PLC with use of CER-host I reach the desktop of Win CE 6.0 find the application file and tried to launch 'DeviceApplication1.exe', but it failed to launch, though none of error reports have been generated by the Win CE 6.0.
Could anyone kindly take me to understanding, generally, what would be possible reasons of failing the application to launch on actual target device?
When you compile a VB6 DLL the compiler adds an exported DllRegisterServer() function to the DLL.
What exactly does this function do?
I do understand that its purpose seems to be to add entries to the registry that allow all the COM magic to work... calling it
"Instructs an in-process server to create its registry entries for all
classes supported in this server module."
But I am interested in a specific, detailed specification for what it does. I haven't found any MSDN documentation on this. Does something like that exist? Has anyone disassembled that code and documented their findings?
Edit: One reason I'm interested in this is that I think there are cases where it doesn't work fully / successfully (even when regsvr32 reports success) and I'd like to understand these potential failure modes better.
The function is used to register the DLL with the windows registry. For example, if you call regsvr32.exe with the DLL name, the DLL will be loaded and then the regsvr32.exe utility will call the DllRegisterServer() function. What the function ought to do from a COM perspective is to make the PROGID, CLSID, and TypeLib entries in the Windows registry so that COM clients can create and use the COM object through CoCreateInstance().
I have created a basic COM DLL with ATL on VS2012. It's called testCOM.dll and it only has one class called CSimpleObj. CSimpleObj has just one method called addValues which adds two values.
I've registered the DLL with Windows 7 64-bit. In VBA, I manually add a reference to the DLL and the below code works properly
Dim Obj As New testCOMLib.SimpleObj
MsgBox Obj.addValues(1,2)
And it give a message with number 3.
Now If I run the vbs which includes:
Dim Obj
Set Obj = CreateObject("testCOMLib.SimpleObj")
It constantly gives an error and is not able to create the object. But if I use the "Excel.Application" ProgID (as an example) for the CreateObject method, it works fine.
I think there is an issue with registering the DLL. I've checked the registry, and the keys for the COM and the type library is already there.
What should I do?
There are three basic requirements to get your COM server to be usable from VBScript:
You need to implement IDispatch so late binding is supported. Not usually a problem with ATL, it implements it by default when you use the wizards.
Your registry script (.rgs) must write the ProgId to the registry. Notable is that you didn't report finding it (look for HKCR\testCOMLib.SimpleObj with Regedit.exe to verify). Its CLSID subkey must match the CLSID in the registry so COM can find your DLL. The ATL Simple Object wizard has a trap, it fills in all the fields when you type the short name. Except for the ProgID field. So very easy to forget.
On the 64-bit version of Windows, you'll execute the 64-bit version of cscript.exe by default. It will not be able to find your 32-bit COM server. You'll need to either build the x64 version of your server or you'll need to use the 32-bit version of cscript.exe, located in c:\windows\syswow64. Not usually a problem with VBA since it tends to be used from a 32-bit version of Office.
The SysInternals' Process Monitor utility is very useful to diagnose these kind of problems. You'll see cscript.exe searching the registry for the keys that your server registered. And probably not finding them, you were however not explicit enough about actual error message you got.
I'm trying to interact with a .dll which will allow me to receive information from a variety of devices (Eye Gaze to be specific). The .dll is called ETUDriver and can be found at http://www.sis.uta.fi/~csolsp/projects.php however it does not come with an accompanying .h file.
I am struggling to actually load, interact and invoke functions from the .dll. A manual is supplied but it is of no help whatsoever with regards to actually setting up the code to start it off. There are three accompanying example apps (with source code) but only two of these work and one of which is in C# so is not helpful. The one that works however loads up the .dll via MFC and this is not a viable option with my code (which is intended to be used with many other projects and as such can't enforce MFC or any other libraries that are not as standard to projects).
Essentially, within the .dll is a series of classes which I need to create within my code and invoke the relevant functions of that class.
I've tried to use HRESULT hr = CoInitialize(NULL);
hr = CoCreateInstance(__uuidof(ETUDSink), NULL, CLSCTX_INPROC, __uuidof(IETUDSink), (LPVOID*)&pETUDSink);
if(pETUDSink)
{
pETUDSink->Start();
} however it always returns an error saying that the class is not registered. I can't use MFC to call the relevant .rgs file and am completely stuck on how to get this to work otherwise.
Is there a given format to doing this that I am unaware of and has anyone had experience in using the ETUDriver (or is able to get it working in C++ without use of MFC)?
Thank you for any help you can provide on this subject :)
I am not familiar with the specific DLL in question, but it sounds like you did not register the DLL on the target machine. You can do this by running regsvr32.exe or by calling the DLL's exported DllRegisterServer function or by using side-by-side assemblies. You need to do register the DLL on each machine that needs to leverage the COM functionality within it, so when you distribute your application, make sure that your installer registers the DLL if you go the regsvr32.exe route.
You can use the #import directive in Microsoft Visual C++ to load the information contained within the DLL without using a header file or rewriting it yourself based on documentation.
I have to make a simple zip file using Visual Studio and VB.NET 2003.
After some googling I got to this page: http://www.digioz.com/tutorials/zip_unzip_vbNET/Zip_and_Unzip_VB_NET_1.html wich basically provides me 3 DLLs with classes that are ready to zip files.
When I try to create an instance of the class like the tutorial tells me to:
Dim zp As New CGZipLibrary.CGZipFiles
I get this error:
COM object with CLSID {293364BA-43F8-11D3-BC2D-4000000A2806} is either not valid or not registered.
Ideas?
If anybody got a better/easier approach to zip files using VB.NET 2003 it would be helpful too.
Thanks.
EDIT:
Thanks for all who answered, but I've used a different approach than the suggested ones to zip my files.
I used the Shell function of the Microsoft.VisualBasic.Interaction class like this:
Shell("zip -j " & fileName, AppWinStyle.Hide, True)
Thanks again for those who dedicated their time trying to help me!
It looks like that library you are trying to use is an old COM dll. That means you have to register the dll first using regsvr32.exe before you can use it. However, I would recommend using a native .NET (managed) library. Unless it doesn't meet your needs, I'd simply recommend looking at the GZipStream class which is part of the .NET framework.
Have you tried this one? This is pretty good: ionic.zip.reduced, a dotnetzip library.
Example:
Using zip As ZipFile = New ZipFile()
zip.AddFile("c:\photos\personal\7440-N49th.png")
zip.AddFile("c:\Desktop\2008_Annual_Report.pdf")
zip.AddFile("ReadMe.txt")
zip.Save("MyZipFile.zip")
End Using
More VB.NET examples of Ionic.ZIP
UPDATE:
Your problem is that VS2003 can't use the targeting of the dll which was created in a newer (eg. VS2005) version of VS. For many have tried to use that, a tool was created which you can download here. For more information, visit this site.
Another option that I use in most of my projects is #ZipLib (SharpZipLib), downloads available here:
http://www.icsharpcode.net/opensource/sharpziplib/Download.aspx
Documentation and samples for both VB and C# are available at the same site. It has specific binary assemblies (dll) for .NET framework 1.1, as well as later versions. It's likely that some of the other libraries that you're run across are compiled for .NET 2.0 or later, which won't work in VS2003.
Don't let the name fool you -- it's written in C# (hence the name) but the compiled assemblies work just fine in VB.NET. It supports Zip, GZip, tar, and BZip2 archives.