Solved

Class not registered - EOleSysError???

Posted on 1998-05-06
27
14,943 Views
Last Modified: 2008-02-01
I have a little problem with one of my programs that loads one specific internet page and evaluates the contents.
I use the THTTP-class and everything works fine on my PC... ONLY on my PC.
As soon as I start the program at university or on a friend's computer, I get the following error message:
"Exception EOleSysError in module s_watch.exe at 00032F45
Class not registered"

I changed the code so it doesn't really do anything when started, but I get the error message anyway - this must be some problem with the classes themselves, not with the "code". It works fine on my PC with both NT and Win95 (dual boot).

Is it possible that the program tries to reference some DLL that is not present on "normal" systems? (I have Delphi 3 on both of my systems). How would I find out if so and which ones??
What else could be the problem and how would I find it? The problem is that everything is fine at home but not on other computers. I can NOT install Delphi on those computers which makes "trial and error" debugging a real pain!!

Any help greatly appreciated!
0
Comment
Question by:Ronald112197
  • 11
  • 9
  • 4
  • +1
27 Comments
 
LVL 1

Expert Comment

by:Odie
Comment Utility
Any ActiveX components your program uses must be registered on the destination machine.  In this case it's probably only html.ocx (C:\windows\system).  You should place this in the system directory of the destination machine and then run "regsvr32.exe" (C:\windows - probably) passing the filename as a parameter ("regsvr32.exe html.ocx").
0
 
LVL 4

Expert Comment

by:d003303
Comment Utility
Yo,
take a look at
http://www.rtfm.be/fpiette/indexuk.htm
A lot of good and free native Delphi internet components ! No pain to register ActiveX controls on all clients.

Slash/d003303
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
Ooops. Shooot!
Asking people to copy the file and run regsvr is not a valid option, so what would I do? Supply an install program (well, should only be a batch file actually...)??

Still not nice at all, because the program should ideally be only one file that can easily be started from a disk or from the network!

Is there any way around this?? I don't use HTML, I only use THTTP to retrieve a URL and evaluate the contents of the page. I don't need any visualization...
Can I use THTTP or do I need to use a different class? Lots of programs use Windows' Internet connection without having to register components...
0
 
LVL 1

Expert Comment

by:Odie
Comment Utility
Well, in that case you'll have to use WinSock or a third-party non-activex control.

Of course a batch-file would do the trick nicely.  Something like:
<<<
@echo off
copy http.ocx %windir%\system
%windir%\regsvr32.exe %windir%\system\http.ocx
>>>

An install program would be better and you could handle errors then.  And what if the http.ocx already exists, etc.  Maybe you should use InstallShield for this.

I don't think you can install the control from the program itself for Delphi checks wether the control is installed at startup.  (You've seen it - your program doesn't even start)

Otherwise, you'll need to use a third-party control.

Hope it helps,

Odie


0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
hmm... looks like using a different component would mean major changes in the code :-((
I guess I'll try InstallShield first - that'll be interesting all by itself because I've never used it so far...*g*

How do I know if I have to include any DLL's? As I said: I can't try it at home (of course it always works!) and it costs me 2-3 days for each "try"

P.S.: I don't have Delphi with me but wanted to try it anyway. I found some page that suggested that i have to register httpct.ocx. When I ran regsvr32, I got the following error-message:
"LoadLibrary("c:\win95\system\httpct.ocx") failed.
GetLastError returns 0x00000485".
I'll look for the *.ocx files on my Delphi CD, but no matter what, I shouldn't get an error message trying to register an *.ocx... any ideas?
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
I tried it on several machines but I can't get it to run!
I even used InstallShield which copies the *.ocx and (as far as I know) tries to register it. I don't get any error messages during installation, but the program still aborts with the same "Class not registered" error :-((

When I "uninstall" my program, InstallShield tells me that httpct.ocx is not used by any application any more and asks if it should be removed - it is in the registry somewhere but obviously not in all the places it should be!!

P.S.: The *.ocx file is the one from the Delphi-CD (i.e. the one from my own hard disk's system directory)
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
hmm... I also added
nmocod.dll
nmorenu.dll
nmsckn.dll
nmw3vwn.dll

Now the program "works", i.e. it starts without error-message, but I get an access violation (Read of address FFFFFFFF) as soon as I access the HTTP-object...

once again: everything works fine on the PCs/HDDs that have Delphi installed, so it must be some missing DLL or registry entry that keeps the THTTP-object (placed on the form) from being inizialized correctly!

Any ideas? Again: I really wonder how you know which files to include!! Is this a guessing game or trial and error????!
0
 
LVL 1

Expert Comment

by:acerola
Comment Utility
i have an answer for that, but i would like to post it
as an answer, not a comment.
unlock this question (i.e. reject the proposed answer)
so that i can give you my answer.
0
 
LVL 1

Expert Comment

by:acerola
Comment Utility
What the hell, here it goes:

I had just the same problem with smtp. Here's how I solved it:

The .ocx libraries have an internal function to register
themselves. The the regsrv32.exe loads the library and
calls this function. I took the source of regsrv32.exe,
modified it a little and put it in my program.
Just call RegisterAxLib('http.ocx') on TForm.OnCreate, or
TApplication.OnException, what ever happens first.
You might need to re-run the application after registering.
You could show a dialog saying "stuff needed to run this app
has just been installed. please re-run me" and terminate the app.
And, of course, you would only run this once. Put some mark
in the computer (e.g. a registry entry) to let the program
know the ocx is installed.

********BOF********

uses
  SysUtils, Windows, ActiveX, ComObj, RegConst;

type
  TRegAction = (raReg, raUnreg);
  TRegProc = function : HResult; stdcall;

const
  ProcName: array[TRegAction] of PChar = ('DllRegisterServer', 'DllUnregisterServer');

procedure RegisterAxLib(FileName: string);
var
  LibHandle: THandle;
  RegProc: TRegProc;
  RegAction: TRegAction = raReg;
begin
  LibHandle := LoadLibrary(PChar(FileName));
  if LibHandle = 0 then raise Exception.CreateFmt(SLoadFail, [FileName]);
  try
    @RegProc := GetProcAddress(LibHandle, ProcName[RegAction]);
    if @RegProc = Nil then
      raise Exception.CreateFmt(SCantFindProc, [ProcName[RegAction],FileName]);
    if RegProc <> 0 then
      raise Exception.CreateFmt(SRegFail, [ProcName[RegAction], FileName]);
  finally
    FreeLibrary(LibHandle);
  end;
end;

********EOF********
0
 
LVL 1

Expert Comment

by:Odie
Comment Utility
It seems that will solve your problem.

Anyway, about knowing which DLLs you need for your program to run, you can use Windows' Quick View.  This lists the imported and exported functions for a program, and the imported dlls.  It doesn't seem to list activex (ocx) controls though.

Oh - acerola,
Why doesn't this control register the regular way?
0
 
LVL 1

Expert Comment

by:acerola
Comment Utility
And what would be the regular way?
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
Quickview was a good idea, but all the DLLs listed there are present on the "destination machine" - yet I still have the problem with the "access violation" :-((
(btw: Quickview doesn't list any of the DLLs I listed above! It didn't work at all without them! Would QuickView know if some DLL references some other DLL?)

What could be missing?
This is becoming a critical problem in my project!!
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
Adjusted points to 125
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:acerola
Comment Utility
httpct.ocx uses nmocod.dll and nmsckn.dll. i dont think it uses the others.

httpct.ocx and nmocod.dll have their internal procedure for registering. use tregsvr.exe or the function i gave you to register them.
if that doesnt work, try using tregsvr.exe with the -t option to register the libs (ocx and dll). i am not sure what is it for, but it might work.
0
 
LVL 1

Expert Comment

by:acerola
Comment Utility
http also uses nmorenu.dll.
nmw3vwn.dll is for html.
nmocod.dll should be registered with the tregsvr.exe -t
httpct.ocx should be registered with tregsvr.exe (without -t)
the source of tregsvr is in
C:\Program Files\Borland\Delphi 3\Demos\ACTIVEX\TREGSVR
tell me if it works. the access violation may be because nmocod was not registered properly. also check out:
C:\Program Files\Borland\Delphi 3\OCX\ISP\Licenses.reg
i dont think these registry entries are actually needed for the ocx to work, but you could try if everything else fails.
0
 
LVL 1

Expert Comment

by:Odie
Comment Utility
About Quickview: it doesn't show wether some dll references another dll.  And with the regular way I mean just registering the ocx and on you go.  I really thought you only needed to register the ocx (my mistake).  And if the ocx needs the other dlls you do need to register them too (probably) with regsvr32 or acerola's function.

BTW - have you tried it on another destination machine than the one you were using for testing?
0
 
LVL 1

Expert Comment

by:acerola
Comment Utility
Well, my quickview shows the import/export table of the dll. It also shows the import/export of the ocx. I just have to rename the .ocx to .dll and call quickview on it. I use win98 rc0.

ocx works just like a dll. regsvr32 and tregsvr call the dll/ocx DllRegisterServer function (that is in the dll/ocx) in order to register it. this is also what my function does.

nmocod.dll is a "type library". it must be registered with tregsvr with the -t option, or this function, also taken from tregsvr source:

********BOF********

uses
  SysUtils, Windows, ActiveX, ComObj, RegConst;

procedure RegisterTLB(FileName: String);
var
  WFileName, DocName: WideString;
  TypeLib: ITypeLib;
  LibAttr: PTLibAttr;
  DirBuffer: array[0..MAX_PATH] of char;
begin
  if ExtractFilePath(FileName) = '' then
  begin
    GetCurrentDirectory(SizeOf(DirBuffer), DirBuffer);
    FileName := '\' + FileName;
    FileName := DirBuffer + FileName;
  end;
  if not FileExists(FileName) then
    raise Exception.CreateFmt(SFileNotFound, [FileName]);
  WFileName := FileName;
  OleCheck(LoadTypeLib(PWideChar(WFileName), TypeLib));
  OleCheck(TypeLib.GetLibAttr(LibAttr));
  try
    OleCheck(TypeLib.GetDocumentation(-1, nil, nil, nil, @DocName));
    DocName := ExtractFilePath(DocName);
    OleCheck(RegisterTypeLib(TypeLib, PWideChar(WFileName), PWideChar(DocName)));
  finally
    TypeLib.ReleaseTLibAttr(LibAttr);
  end;
end;

********EOF********
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
sorry guys... I'm quite busy at the moment, but I'll try the above as soon as I can... Just wanted to make sure this question won't be autograded and let you know that I haven't forgot about it...

    C U soon and thx so far!
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
still too busy... this is complicated and will take some time. For some reason my ActiveX controls don't want to work...

I just don't want anybody to get an automatic C for a good answer...
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
hmm... I'm having exams right now and no time to try complicated stuff.
This is what I'm doing right now: I stopped using ActiveX controls, because either way, installation seems to be more complicated than it should be.

So who should get the points now?
Odie, because he told me why I get the error message?
d003303, because he proposed the component I now use?
acerola, because he told me how I could fix the problem? (I assume it would work, but haven't tried it yet)??

What do you say?
0
 
LVL 4

Expert Comment

by:d003303
Comment Utility
Up to you.
0
 
LVL 1

Expert Comment

by:acerola
Comment Utility
Huh, that's a complicated question... I think no one will answer it for less than 500 points...
0
 
LVL 4

Expert Comment

by:d003303
Comment Utility
Just another thing not related with the solution of this prob. It came to me when I was reading through the whole thread again.
A better tool to explore DLL dependencies is Borlands TDUMP utility in the delphi?\bin directory. Put it in your path and call it with e.g. "tdump somedll.dll | more" and you get much more information than QuickView gives.

Slash/d003303
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
ok, let's put an end to this discussion. I'm really sorry, but I don't currently have the time to try all of the above, especially since I use a different component now and the problem is not so pressing any more.

Now what bout the points?

The winner iiiiiiiiiiis:

acerola

because I guess he put the most effort into this answer and it probably would have been the best solution for my problem - other than using a non Active-X component. I think d003303 has enough points I guess and only posted a few lines :-))

Thanks a lot Odie! Your comment helped but for some reason didn't solve my problem. It's possible that it should have, but somehow it didn't :-( Thanks a lot anyway

acerola: Did I understand correctly that I can use EITHER tregsvr OR your function?
Why didn't InstallShield correctly register the components/DLLs when I included them in the setup file? As far as I know, it is supposed to register everything it installs!
0
 
LVL 1

Accepted Solution

by:
acerola earned 120 total points
Comment Utility
InstallShield and regsvr32.exe  register .ocx, but only tregsvr with the -t option, or my second function, register type libraries (nmocod.dll).
My functions are taken from the tregsvr source code, so you may use either one.

You know, one thing I don't like about the delphi experts here is that when you ask a question on how to do something, they don't teach you how to, they give you a ready-made component for you to use instead of delphi original ones. I myself don't like using other's components, unless I have the source code.
0
 
LVL 2

Author Comment

by:Ronald112197
Comment Utility
So if InstallShield does not register the DLLs, how do I provide an install program that "makes it work" without including special code to register components in my program??

About the components: I agree. I also once asked about getting the build number and project version from the exe-file and somebody gave me a huuuge components that retrieved all available information. It was a nice component, but I didn't manage to figure out which part of the code read the version info! A little later, somebody posted about twenty lines that did the job! On the other hand, I was quite happy to get a good http-component (since I couldn't get the OCX to install) because it would have been quite a pain to write one!!
0
 
LVL 1

Expert Comment

by:acerola
Comment Utility
Well, I don't know much about InstallShield. I just use it when my program needs to use the BDE. But you could make yourself a install program in delphi that does all the stuff.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now