Solved

Compiler problem ( faster may be able to help)

Posted on 1998-10-18
16
400 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

21 Experts available now in Live!

Get 1:1 Help Now