|
QUESTION 1:
i typed at the command prompt:
C:\somefolder\regsrv32 mysever.dll
Error from regsrv32: "myserver.dll" is not an executable file and no registration help is registered for this file type.
and
C:\somfolder\regsrv32 /u myserver.dll
Error from regsrv32: same as above.
It's an ATL-Wizard created COM btw.
QUESTION 2:
btw, I also tried to register and unregister with WinExec. Is there anything wrong? forward slashes Vs back slashes?
#include "stdafx.h"
#include <windows.h>
#include <iostream.h>
int main(int argc, char* argv[])
{
int nRetCode = 0;
nRetCode = WinExec("RegSvr32 /u C:\Program Files\RealTime7\QueryGenAlpha\QueryGenAlpha.dll", SW_SHOW);
if(nRetCode <= 31)
{
cout << "WinExec failed..." << endl;
}
return 0;
}
The error was not reported thru the console (ie. nRetCode>31), but:
(a) A pop up from regsvr32 appeared, and:
"LoadLibrary("C:Program" failed - the specified module cannot be found"
(b) I also tried to call LoadLibrary from client directly. But LoadLibrary failed. And GetLastError() reported after call to LoadLibrary:
193 is not a valid Win32 application. ERROR_BAD_EXE_FORMAT
Code as follows:
HINSTANCE hLib;
hLib = LoadLibrary(_T(pszDll));
//STEP 2: un-register server
if(hLib!=NULL)
{
PFUNC pFunc = (PFUNC) GetProcAddress(hLib, _T("DllUnregisterServer"));
if(pFunc!=NULL)
{
//Unregister the server!
pFunc();
}
else
{
//Additional exception handling here.
dwError = GetLastError();
return 0;
}
}
else
{
//Additional exception handling here.
dwError = GetLastError();
return 0;
}
One last thing: When I build (Ctrl-F5) the ATL COM server project, I had no problem at all. THe server get registered, and I tested the server from VB client and it worked!
Thanks!
norm
|
|
|
|
|
just found this link:
http://support.microsoft.com/default.aspx?scid=KB;en-us;q249873
not sure if i can spot the problem....
norm
|
|
|
|
|
i figured out the problem, the dll was corrupted in the process of copying it from CD to destination folder.. anyway, i fixed that. Now i tried to LoadLibrary to access DllUnregisterServer and DllRegisterServer...
i load the dll via LoadLibrary and called:
STEP 1: GetProcAddress(hLib, _T("DllUnregisterServer")
proceed to un-register the dll.
STEP 2: GetProcAddress(hLib, _T("DllRegisterServer")
proceed to register the dll.
i still have some trouble. i lauch the VB client and it stop working. tried to open keys from registry and registry complained "error openning key" ... (somehting close to that)
since DllRegisterServer is implemented by ATL Wizard, I assume there's nothing wrong with it (MS never produces buggy code right? )
so, THREE prime suspect:
SUSPECT 1:
PFUNC pFunc = (PFUNC) GetProcAddress(hLib, _T("DllRegisterServer")); //SUSPECT 1: Name mingling.. but pFunc is NOT NULL. So, this is cleared.
if(pFunc!=NULL)
{
//register the server!
pFunc();
}
SUSPECT 2:
typedef void (*PFUNC) (void);
does it matches the signature of..?
STDAPI DllRegisterServer(void)
I am a bit confused by STDAPI, but I just ignore it for the moment... But SUSPECT 2 is the only remaining p
ossibility i can see.
SUSPECT 3:
the installation program i write now call DllUnregisterServer before installing a clean copy. But the old dll may reside in a different folder.
if I call DllUnregisterServer by loading the new dll (in attempt to unregister the old dll...?) you think this will be a problem?
SUSPECT 4:
RegSvr32 does more than just load the dll and call DllRegisterServer and DllUnregisterServer. Developer should not attempt to call these two methods directly and should stick with RegSvr32?
norm
|
|
|
|
|
hi
have you tried this?
nRetCode = WinExec("RegSvr32 /u \"C:\\Program Files\\RealTime7\\QueryGenAlpha\\QueryGenAlpha.dll\"", SW_SHOW);
|
|
|
|
|
thanks for the feedback... i tried, and it worked just well:
char szCommand[300];
for(i=0; i<300; i++)
{
szCommand[i]='\0';
}
strcpy(szCommand, pszQueryGenDir);
strcat(szCommand, "/RegSvr32.exe QueryGenAlpha.dll");
WinExec(szCommand, SW_SHOW);
but RegSrv32 pop up is really annoying... I cant get LoadLibrary working unfortunately..
i'm suspecting that something is wrong with the function pointer:
typedef HRESULT (STDAPICALLTYPE *PFUNC)() ; //OPTION 1: It worked!!?
//typedef void (*PFUNC) (void); //OPTION 2: It Does NOT WORK???
WHY????
Here's the code:
int i = 0;
DWORD dwErr = NULL;
OleInitialize(NULL);
typedef HRESULT (STDAPICALLTYPE *PFUNC)() ; //OPTION 1: Requires stdole.h
//typedef void (*PFUNC) (void); //OPTION 2: Wont work unfortunately. U wont even get a compiler/RT error.
char * pszDll = NULL;
pszDll = new char [300];
for(i=0; i<300; i++)
{
pszDll[i] = '\0';
}
strcpy(pszDll, pszQueryGenDir);
strcat(pszDll, "\\QueryGenAlpha.dll");
//STEP 1: Load dll.
HINSTANCE hLib;
hLib = LoadLibrary(_T(pszDll));
dwErr = GetLastError();
//STEP 2: register server
if(hLib!=NULL)
{
PFUNC pFunc = NULL;
pFunc = (PFUNC) GetProcAddress(hLib, _T("DllRegisterServer"));
dwErr = GetLastError();
if(pFunc!=NULL)
{
//register the server!
pFunc();
dwErr = GetLastError();
}
else
{
//Additional exception handling here.
FreeLibrary(hLib);
return 0;
}
}
else
{
//Additional exception handling here.
return 0;
}
dwErr = GetLastError();
FreeLibrary(hLib);
delete [] pszDll;
OleUninitialize();
Thanks
norm
|
|
|
|
|
hi
have you traced the program execution? does it get to the
pFunc() calling? does it come out of that call back to
your program?
|
|
|
|
|
it did work, for whatever odd reason. all that i changed was the typedef, as i indicated earlier.
i dont understand it. just followed as instructed. be nice if someone can give a bit of explanation though.
norm
|
|
|
|
|
Debug Assertion Failed!!
Program: c:\myproject\myprogram.exe
File: olecli3.cpp
Line: 502
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts
What would be the reason of getting this error message and why I didnn't get it before. The program get no changes, I simply go to debug folder and double clicked on the exe file to run my program... the program was working fine prior to the time I got this error message. After that, I can't event run my program at all.
what would be causeing this error??
Thanks you
|
|
|
|
|
File: olecli3.cpp
Line: 502
Make sure you don't look at the above file at the above line, as it could give you a strong hint at what is going wrong.
Seriously, go to that file at that line, and there is agood chance you figure out what is wrong. If not, post the content here (with some context) and we may be able to help you.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
that olecli3.cpp file is not in my project. it is a mfc cpp file.
and the run time error is in InitStance() method in projectApp file. the following code is created when you create the new project with ole support and that's where i got the run time error occure. What suprised me is I got no error or anything and the program run perfectly. but next time.. I run it again. there it is, the run time error occured there
<br />
if (RunEmbedded() || RunAutomated())
{<br />
COleTemplateServer::RegisterAll();<br />
}<br />
else<br />
{<br />
COleObjectFactory::UpdateRegistryAll();<br />
}<br />
|
|
|
|
|
Does anyone know how to use Visual InterDev/J++ Utility Projects (*.VUP) for a VC++ project? I know it's possible, but I don't know how to do it. I'm using Visual Studio 6.0 Professional Edition.
David
|
|
|
|
|
hi everyone,
i have a question about doc/view architecture.. i use odbc on my sdi, based on listview, application.. i have created a odbc object, m_db, in the myappDoc class. whenever i want to access to the database from the myappView class, i use these codes "mydb * dbobj = &GetDocument()->m_db".. my question is if i created a dialog in my sdi application, how do i access to the "m_db" odbc database object? thx in advance..
|
|
|
|
|
My usual way is to pass a pointer to the CDocument derived class as parameter of the dialog's constructor. This pointer is then assigned to a member variable.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
I suppose there are two ways:
1. Add a member "m_db" to your dialog's class and set it when you construct the object, right before calling DoModal.
2. Use the global CWinApp to get the document object and then m_db from there. I don't recommed it, but the code would look something like this:
CDocTemplate* pDocTemplate = AfxGetApp()->GetNextDocTemplate(AfxGetApp()->GetFirstDocTemplatePosition());
CYourDocument* pDoc = (CYourDocument*)pDocTemplate->GetNextDoc(pDocTemplate->GetFirstDocPosition());
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hello,
I'm having the following problem. I've been developping with the Messenger Typelibrary in both VB and Delphi for quite a while now. As I wanted to switch to C++, I downloaded the headers and lib file that Microsoft gave free for download on their site. All seems to be more or less ok, I see all the classes, but NO EVENTS! None whatsoever. When I try to add a member function it says that the implementation is not found. I need the OnTextReceived event for instance, I can't find it anywhere. Not in the headers, not in the help that came with it either!
After a bit of searching on the MS Site I found a similar function DOES exist in the Exchange API, I don't see how those 2 are connected, if they even are...
Can anyone help me? Is it not possible in C to pull a trick like VB or Delphi? Just import the msmsgs.exe?
Thanks a lot,
- Fahr
|
|
|
|
|
Looking through the messenger sdk headers, there seems to be a lot of events although I can't see one for OnTextReceived.
Have you tried using #import on the Messenger Typelibrary and see if that generates the missing events. It is possible that the SDK uses an earlier/later version of the COM interfaces?
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
The main problem with that is that the actual typelibrary is in the msn executable... I have NO idea how to import it :S
Neither do I have any idea how to import type libs in C w/o header files in general :P
- Fahr
|
|
|
|
|
#import "C:\Program Files\Messenger\msmsgs.exe"
will generate you a header file for the typelib. I've checked with my version and it generates an event for OnTextReceived.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
possibly and extremely stupid newby question: WHERE do I type the #import so it generates a class/header/whatever ??
I never worked with typelibs in C w/o having pre-made headers :S
Thanks,
- Fahr
|
|
|
|
|
#include "stdafx.h"
#import "C:\Program Files\Messenger\msmsgs.exe"
int _tmain(int argc, _TCHAR* argv[])
{
Messenger::IMsgrObject2Ptr oMsgrObj = NULL;
Messenger::IMsgrUsersPtr oUsers = NULL;
Messenger::IMsgrUserPtr oUser = NULL;
oMsgrObj.CreateInstance("Messenger.MsgrObject");
oUsers = oMsgrObj->GetList(Messenger::MLIST_CONTACT);
return 0;
}
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
Thanks an amazing bunch!! It works!!
Will it compile the exe along so I only need a running instance, or will it need the exe to be always in the same dir?
- Fahr
|
|
|
|
|
It only uses the exe to generate the msmsgs.tlh, msmsgs.tli files. The exe is just acting as the type library. As long as MS Messenger is on the machine that you install on, then your app will just run.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
Also, I stumble upon the following error when I try to define the OnTextReceived function:
c:\program files\microsoft visual studio\myprojects\msntest\stdafx.cpp(23) : error C2084: function 'long __thiscall Messenger::DMsgrObjectEvents::OnTextReceived(struct Messenger::IMsgrIMSession *,struct Messenger::IMsgrUser *,class _bstr_t,class _bs
tr_t,short *)' already has a body
what am I supposed to do with that? I'm guessing it is redifined or something?? I don't get it...
Sorry if I sound too much like a noob, this is all just new to me :P
And on another note, can I make it like a class in my classview? It would be a lot easier I think...
Thanks,
- Fahr
|
|
|
|
|
Hi,
I wrote a class for an ownerdraw listbox (LBS_OWNERDRAWFIXED). When used as a child window, MeasureItem and DrawItem are correctly called.
When used as a popup, these methods are not called (neither OnMeasureItem and OnDrawItem in the owner window).
How to have an ownerdraw listbox used as a popup ??
Thanks
|
|
|
|
|
When i save my MDIDocument I want to speicify the Default File Extension for the Document. Where and how should i do it ?
|
|
|
|