 |
|
 |
I suggest that in the function params replace LPCSTR lpszLibrary with LPCTSTR lpszLibrary This will accept either the unicode or ANSI string depending on project settings.
But, FYI GetProcAddress doesn't accept unicode strings so those strings should be ANSI.
|
|
|
|
 |
|
 |
why this:
else
{
va_end( va );
return FALSE;
}
va_end( va );
return TRUE;
}
but not just this?
va_end( va );
return TRUE;
i mean, why did you write the last "else" at all? is it really necessary?
|
|
|
|
 |
|
 |
Huh? If the else is removed than when load library fails we would still return TRUE, which is wrong.
|
|
|
|
 |
|
 |
Oh, of course. Obviously I haven't paid enough attention, sorry for confusion.
|
|
|
|
 |
|
 |
i need explain setp by setp how can make dll with matlab to call it in C/C++
and its demo
Heba
|
|
|
|
 |
|
 |
Hi i am interested in calling my DLL in Matlab.
Shall i convert my VC++ code into C- MEX file and then call it in Matlab command line, or is there an easier way?
Thanks!
Great job here by the way, keep it up!
|
|
|
|
 |
|
 |
Hi,
I have an c++ dll and i am trying to call method from c++ dll.I am getting "Runtime error 53" File Not Found:"C:\.......\test.dll".The dll is present in the specified library.
When i try to build the dll code from VC++ it gives me Warning ... "_run time exception".
Where i am doing mistake?
TIA.
Regards,
Devaraj
|
|
|
|
 |
|
 |
which method use dll?
Are you use Loadlibrary. Verify the path location.
Vijayan
|
|
|
|
 |
|
 |
I have created an API(Adobe Acobat 7.0)
In many case,the dll is not loading (few
dependency fles are missing)but I don't know ,exactly how to debug DLLs.
|
|
|
|
 |
|
 |
My friend made MATH.ddl in which has a function named SUM(int x, int y) (I just khow the function and its parameters, I don't know the entails code in it). On a nice day, I want to override the SUM(x,y) of my friend (not make a new dll), just to hide my friend function by my function SUM(x,y) ver 2.0 (^ ^).How can I do that?
|
|
|
|
 |
|
 |
If both, the method signatur "SUM(int x, int y)" is equal for the DLL-method and your own implementation there will be no conflicts because the DLL method is referenced by GetProcAddress().
Just modify the pointer to the DLL function (give it another name):
typedef int (int *sum)();
sum add;
HINSTANCE hinstDLL = LoadLibrary("MATH.ddl");
... add = (sum)GetProcAddress(hinstDLL, "sum");
add(1,2); sum(1,2);
|
|
|
|
 |
|
 |
Hi,
I got an error adding ou_thread.cpp, and this say something like:
C:\JOSE PROJECTS\TSVR\ou_thread.cpp(301) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.
I commented even all #includes and its the same...
Thanks in advance..
|
|
|
|
 |
|
 |
Fatal Error C1010
Error Message
unexpected end of file while looking for precompiled header. Did you forget to add '#include name' to your source?
An include file specified with /Yu is not listed in the source file. This option is enabled by default in most Visual C++ Project types and "stdafx.h" is the default include file specified by this option.
In the Visual Studio environment, use one of the following methods to resolve this error:
*
If you do not use precompiled headers in your project, set the Create/Use Precompiled Header property of source files to Not Using Precompiled Headers. To set this compiler option, follow these steps:
1.
In the Solution Explorer pane of the project, right-click the project name, and then click Properties.
2.
In the left pane, click the C/C++ folder.
3.
Click the Precompiled Headers node.
4.
In the right pane, click Create/Use Precompiled Header, and then click Not Using Precompiled Headers.
*
Make sure you have not inadvertently deleted, renamed or removed header file (by default, stdafx.h) from the current project. This file also needs to be included before any other code in your source files using #include "stdafx.h". (This header file is specified as Create/Use PCH Through File project property)
|
|
|
|
 |
|
 |
I need to call function in a VB 6.0 DLL from Matlab using the most direct route possible.
I have been able to get Matlab to call a C DLL, which calls a C++ DLL, which calls a VB 6.0 DLL. Is their a more direct route (like having the C DLL call the VB DLL)?
Here is the method I am currently using:
VB 6.0File->New->Active X DLL
Project name: Project1
Class name: Class1
Function name: blah
Public Function blah() As Integer
blah = 99
End Function
MSVC++ 6.0File->New->Win32 Dynamic-Link Library
Project name:theCppDll
Copy VB 6.0 Project1.dll to working directory of theCppDll project
theCppDll.h
#ifndef _THECPPDLL_H_
#define _THECPPDLL_H_
extern "C" __declspec(dllexport) int blob(void);
#endif
theCppDll.cpp
#include "windows.h"
# import "Project1.dll"
using namespace Project1;
extern "C" __declspec(dllexport) int blob(void)
{
int x;
HRESULT hresult;
CLSID clsid;
CoInitialize(NULL); //initialize COM library
hresult=CLSIDFromProgID(OLESTR("Project1.Class1"), &clsid); //retrieve CLSID of component
_Class1 *t;
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_Class1),(LPVOID *) &t);
if(FAILED(hresult))
{
return(200);
}
x = t->blah (); //call method
t->Release(); //call method
CoUninitialize(); //Unintialize the COM library
return(x);
}
MSVC 6.0File->New->Win32 Dynamic-Link Library
Project name:theCppCall
Copy MSVC++ 6.0 theCppDll.dll to working directory of theCppCall project
theCppCall.h
int __stdcall addInts(int x, int y);
theCppCall.def
LIBRARY myCdll
DESCRIPTION 'myC DLL'
EXPORTS
addInts;
theCppCall.c
#include "theCppCall.h"
#include "stdio.h"
#include "windows.h"
typedef UINT (CALLBACK* LPFNDLLFUNC1)(VOID);
int __stdcall addInts(int x, int y)
{
HINSTANCE hLib = LoadLibrary("theCppDll.dll");
LPFNDLLFUNC1 myBlob;
UINT uRetVal;
if(hLib == NULL)
{
printf("Unable to load library");
return (201);
}
myBlob = (LPFNDLLFUNC1)GetProcAddress(hLib, "blob");
if (myBlob == NULL)
{
printf("Unable to load function");
return (202);
}
uRetVal = myBlob();
x = uRetVal;
return (x+y);
}
Matlab 7.0Copy theCppCall.h and theCppCall.dll into the working directory
>> loadlibrary theCppCall theCppCall.h
>> libfunctions theCppCall –full
>> calllib(‘theCppCall’, ‘addInts’, 2, 3)
>> unloadlibrary theCppCall
Note that this is a totally useless function, but does demonstrate how each program calls a DLL from another program. The addInts program adds 2 arguments, but the first argument is overwritten by the value (99) retrieved from the VB DLL. So the addInts function adds 99 to the second argument.
Matlab calls the addInts function using a MSVC 6.0 DLL
MSVC 6.0 calls the blob function using a MSVC++ 6.0 DLL
MSVC++ 6.0 calls the blah function using a MSVB 6.0 DLL
|
|
|
|
 |
|
 |
Hi all
My DLL is provided by some other person and hence i dont have the .h file but he has provided me .lib files and .dll files.I dont know how to link it implicitly.Please help me.
|
|
|
|
 |
|
|
 |
|
 |
Hi,
VC++ 6.0 - Go to project settings ->Link -> add your .lib file name Object Module\libraries.
VC++ 7.0 - Project properties -> Linker ->Input -> Add your library file in Additional dependancies
Ensure that you keep the .lib and .dll file in the project folder.
Devaraj
|
|
|
|
 |
|
 |
I've created an simple ATL project in VS7. It compiles successfully but it will not register its RGS settings. I've even tries running regsvr32 manually (it is successful) but it does not write anything to the registry!?!
When I create a ATL project with the 'attributed' option turned off the RGS settings get written. But with attributed on it does not work.
What am I doing wrong?
Thanks in advance.
Christian.
|
|
|
|
 |
|
 |
- 1st check for the right privilleges to write into the registry.
- 2nd post some code if there are any furhter problems.
|
|
|
|
 |
|
 |
I have some problem with inpout32.dll
in win32 console application project, my code is:
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
/* ----Prototypes of Inp and Outp--- */
void _stdcall Out32(short PortAddress, short data);
/*--------------------------------*/
/*
int main()
{
Out32(888,20);
return 0;
}
but in MFC project ,it error (i use the same code ,except
int out()
{
Out32(888,20);
return 0;
}
Linking...
thulpt1Dlg.obj : error LNK2001: unresolved external symbol "void __stdcall Out32(short,short)" (?Out32@@YGXFF@Z)
Debug/thulpt1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
thulpt1.exe - 2 error(s), 0 warning(s)
how can i solve it ?
please help me
dnqhung
|
|
|
|
 |
|
 |
Hi dnqhung,
if you want to use the inpout32 library then take the following steps:
First, copy the inpout32.dll and inpout.lib files into your project directory. inpout.lib can be found in the VC_test_app directory. Now go to the project properties page, click through Configuration Properties->Linker->Input. Where it says Additional Dependencies add "inpout32.lib" to the list.
Next you need to include the function declarations somewhere in your project:
void _stdcall Out32(short PortAddress, short data);
Now you can just call either of those functions to send or receive data on the parallel port. Normally, the port address is 0x378 but you shouldn't rely on that.
|
|
|
|
 |
|
 |
I developped a program to communicate on serial port com. It works fine on xp/W2000.
Then I wanted to include this into a bigger project, so I decided to change it into a dll. It works fine on W2000, but the same application using the same dll NEVER works on WXP. Does anybody have an idea about what could happen?
When I say it never works I mean that the thing that reiceives the data transferred on the serial link (I see the data transferred via a spy on the link) does'nt act as it really reiceived everything OK.
THANKS for your help!!!!
|
|
|
|
 |
|
 |
Hai
In my project i had loaded Resourcesdll in
InitInstance() function. After it get's loaded i
want to load the someother resourcedll based on user
click on button.
My question is how to load different resoucrcedll
at runtime.?
Regards
sakthi
|
|
|
|
 |
|
 |
Look for LoadLibrary() and GetProcAddress() in the MSDN.
|
|
|
|
 |
|
 |
I'm currenty writing an application which indexes a list of 'plug-ins'. Here's the piece of code that creates the index of al valid plug-ins:
void BuildPluginList()
{
CFileFind finder;
PluginList.RemoveAll();
if(!finder.FindFile(".\\Plug-ins\\*.dll"))
AfxMessageBox("Can't find Plug-in directory", MB_ICONHAND, NULL);
unsigned long dllCount = 0, pluginDllCount = 0;
CString filename; HMODULE hmod;
BOOL isMore = TRUE;
while(isMore)
{
isMore = finder.FindNextFile();
dllCount++;
CFile f (finder.GetFilePath(), CFile::modeRead | CFile::typeBinary);
hmod = ::LoadLibraryEx(finder.GetFilePath(), (void*)f.m_hFile, LOAD_WITH_ALTERED_SEARCH_PATH);
if (GetProcAddress(hmod, ("OhDuh"))
{
pluginDllCount++; PluginList.Add(finder.GetFilePath());
}
}
The code won't work. If the 'Plug-ins' directory contains 5 DLLs, whereof 2 real plug-ins (that is, when they have the function 'OhDuh'), dllCount will be 5 (correct), but pluginDllCount will be zero (not correct).
When I paste a GetLastError after the LoadLibraryEx, I get a sharing violation error (32).
Why?
|
|
|
|
 |