Solved

Compiler problem ( faster may be able to help)

Posted on 1998-10-18
16
388 Views
Last Modified: 2013-12-03
Hi again
I am using BC4.52 and in my program am using the RegOpenKeyEx()  function. In fact I copied an example that
'faster' gave in an anwer to someone.
The other day when I compiled it, everything worked, but now I get this linker error.

Linking regread.exe:
Linker Error: Unresolved external 'RegOpenKeyExA(HKEY__*,const
char*,unsigned long,unsigned long,HKEY__**)' referenced from module
REGREAD.CPP

Does any-one know what it means AND how to solve it.
Regards
David Schmider

0
Comment
Question by:dsch
  • 6
  • 5
  • 2
  • +2
16 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1415362
Go to the your project settings and add advapi32.lib to the link option.
0
 
LVL 1

Author Comment

by:dsch
ID: 1415363
How do I do that in the IDE?
0
 
LVL 1

Author Comment

by:dsch
ID: 1415364
chensu, I do not have this file (advapi32.lib) on my computer anyway so how could it work before?
I have to re-open the question
Thanks anyway
David

0
 
LVL 23

Expert Comment

by:chensu
ID: 1415365
I don't have the compiler you are using. But advapi32.lib should be there.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1415366
Test you project to Win32 Platform(not Win3x(16)!)
For this open View|Project, go to Name of Target,
right button of Mouse, TargetExpert and change Platform.
This function works  only in Win32 Platfrom!
Regards, Alex
0
 
LVL 1

Author Comment

by:dsch
ID: 1415367
Alex
No it is definatley a win32 app, I think chensu was right regarding the lib file. Sorry :-(

chensu,
Hi there again. I think you are right, with what you said.
So I have tried to use the IMPLIB feature on BC4.52 using the command from D:\BC45 directory
IMPLIB -w ..\LIB\advapi32.LIB c:\w95\system\advapi32.dll

This is supposed to create the lib file from the dll file. However it gives me this message:

>>
D:\BC45\LIB>IMPLIB -w ..\LIB\advapi32.LIB c:\w95\system\advapi32.DLL

Turbo Implib Version 2.0 Copyright (c) 1991, 1994 Borland International

Exception C0000005: Access violation
Module: IMPLIB.EXE Start address: 00410000
EAX=006A1300 EBX=79DC77F3 ECX=FFFFFFFF EDX=006A1380 ESI=006A1180
EDI=79DC77F3 EIP=00416757 EBP=0068FCB8 ESP=0068FCB4 EFL=00010246
>>

If you resubmit your message I will accept it.
And if by any chance anybody has a copy of the advapi32.LIB file,
please could you email it to me at
dschmider@iname.com

Thanks so much
David

0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1415368
1) make sure you are not declared RegOpenKeyEx anywhere in your program (windows.h make it for you) -  its very important (i'm not seen 'faster' example, it whould be better if you past it here as comment)
2) you need no to link advapi32, or use implib, because all imports for Win32 already in Borland's import32.lib.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1415369
I'm sorry, type errors in my answer:  ... it would be better if you post it ...

0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 15

Expert Comment

by:NickRepin
ID: 1415370
Also, you may try to 'rebuild all' your project.
May be, there is a problem with Borland C installation - you may try to re-install it.

Again, you should not care about import libraries in Borland C - compiler do it for you.

Probably, this link error may exist if you declared RegOpenKeyEx in your app, and you compile it in C++ mode.

Also, do not include <winreg.h> - all declaration already in <windows.h>
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1415371
dsch - I have sent two different copies of the file you mentioned to the account dschmider@iname.com.  If you have any problems getting the file, please reply to the email or post here.  Good luck!
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1415372
For Borland C++, the problem is not in advapi32.lib.
Borland even doesn't ship it in installation.
0
 
LVL 1

Author Comment

by:dsch
ID: 1415373
It does not seem to be a compiler problem, as I have reinstalled it. I think this may be something in the program that has caused it to happen.
Does any one think it is unusual to have 2 ** in a message like this:
Linker Error: Unresolved external 'RegOpenKeyExA(HKEY__*,const
char*,unsigned long,unsigned long,HKEY__**)' referenced from module
REGREAD.CPP
ie HKEY__**  . I have never remembered seeing that before
I will see what I can find.

thresher_shark: just to say thanks for the files, although it didn't solve the problem. It was very kind of you.
David

0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1415374
No problem, it was worth a shot. :-)
0
 
LVL 1

Author Comment

by:dsch
ID: 1415375
Hi there, (Very sheepish and embarassed) :-|
You are not going to believe this, but I copied and pasted the same code into another program and it all worked.
(So it had to be something in my code.)
I then searched all files that contained text "RegOpenKeyEx" within my included .cpp files, and I found that I had put another declaration for the RegOpenKey function in one of the far outpost .cpp files.
I usually copy & paste out of the help into my source code, then fill in the parameters so I don't miss one out. But for some reason I have left it in.
Perhaps it was late at night. (Yawn)
Obviously, this is another reason why nobody pays me to do this stuff yet!
Any way,
Thankyou for all your help, and I apologise for wasting anyones time.
Best Regards to you all
David Schmider
This is the hardest Submit button I have ever had to click in my life... Here goes...

0
 
LVL 15

Accepted Solution

by:
NickRepin earned 50 total points
ID: 1415376
dsch, please do read my previous (and rejected by you!) answer with little bit more attention:

>1) make sure you are not declared RegOpenKeyEx anywhere in your >program (windows.h make it for you) -  its very important

As you see, I've offered right solution for you 2 days before.
0
 
LVL 1

Author Comment

by:dsch
ID: 1415377
Nick
Good point, I apologise profusely. Trust me! not only can I not program, I can't read either. :-)
Thankyou so much and Best Regards
David
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

708 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

15 Experts available now in Live!

Get 1:1 Help Now