When using the following line code in Delphi 2010, a'm getting an "Access Violation" error, but the same code working fine in VC++.
The Delphi 2010 code is
var
hMyInf : HINF;
begin
hMyInf := SetupOpenInfFile('.\\DIGIMHID.INF','Mouse', INF_STYLE_WIN4,Nil);
The VC++ code is
hMyInf = SetupOpenInfFile(".\\DigimHID.inf", "Mouse", INF_STYLE_WIN4, NULL);
Please help me to solve this issue.
Thanks All.
Call LoadSetupAPI before using any methods in the SetupAPI.pas
Edit, to provide some background: As simultaneously wrote by David in his answer and by me in my comment, the error is probably caused by calling an uninitialized method pointer. For me the first tip was the error message, an Access Violation: If the equivalent of an Access Violation came from Windows itself, it'd be called a Runtime Error 216. The code is very simple, only uses constants and a method call. Constants can't generate AV's so the error had to come from the method itself, or from calling the method.
Since the Delphi declaration supplied showed a "function type", I suspected SetupOpenInfFile is actually an method pointer, not an import method. Those pointers need to somehow be initialized. Searching SetupAPI.pas (thanks google for providing a link, because I don't use JEDI libraries) I quickly found that it's being assigned from LoadSetupAPI. My first thought: isn't LoadSetupAPI called from the initialization section? It's not, so it needs to be called from code. Problem solved.
Your filename is wrong in the Delphi version. You don't escape \ in Delphi, a single one will do. But that wouldn't lead to an access violation.
My guess is that your GetProcAddress call is failing. But that is a guess. I'd like to see more code and the full error message.
EDIT
It seems that we were on the right track. Cosmin's answer will solve the problem for you. An alternative would be to switch to inplicit linking by removing the definition of the condition SETUPAPI_LINKONREQUEST in SetupApi.pas.
Related
The instructor in the C++ course I'm following used this code here, and I copied it exactly:Code the course instructor used
But I get this error. Not sure what to do. I know that the instructor is doing this in 4.27 and I'm doing it in 5.1. Did something change between those two versions that may have caused this error? How to I get around it?
The error I'm receiving
Here's my whole function for reference:
Whole function
I also faced this problem. Here is the workaround.
For UE5.1 you need to write this in your file, #include "Engine/DamageEvents.h".
Compiling a rather large project (>750K lines) with delphi XE3 (upgrading from 2009)
Getting the following error
[dcc32 Fatal Error] MainForm.pas(3170): F2084 Internal Error: URW1147
Similar to this question, however nowhere in the code are generics used.
internal error with generic array
The error does not correspond to a line of code, but rather just the end of the file.
I.e. after the "end."
Following a google search I have also tried all settings for "Code inline control", but no joy.
Not sure where (else) to start looking and would appreciate any educated feedback (or maybe even a wild guess).
Have not yet put in a QC report pending hopefully usefully feedback from here.
Thanks
Have resolved this issue by stripping back the code a section at a time as per David's suggestion above.
Solution is was follows in case this is helpful to anyone...
Turns out there was a 'left over' fragment of 'generics' code which was thought to have been removed several years ago and replaced using more traditional techniques.
There was single local variable which was not refactored, defined as follows.
var
TestProc: TProc;
when assigned as per the following, the internal compiler error is triggered (however nowhere near the offending line of code).
TestProc := TestSuite.TestProcs[i].TestProc;
The array element TestProc above is of type procedure of object.
This compiles (and works perfectly) under 2009 which was why it wasn't picked up earlier, but gives an internal compiler error under XE3.
Correcting the local variable declaration (to procedure of object) fixes the problem.
I'm trying to connect my Windows XP program (Lazarus) to my Ubuntu postgres server.
When the Lazarus program runs, it seems to compile fine but I get this error:
Project ... raised exception class 'RunError(211)'.
Then it terminates execution (and I don't see any output), and opens up a file customform.inc. In that file, it shows a procedure procedure TCustomForm.DoCreate; where it highlights a line: if Assigned(FOnCreate) then FOnCreate(Self);
I believe this is one of the system's files.
I never get to see any output.
What could this be? Thanks!
MORE INFO:
I've narrowed down the error to this line:
dbQuery_Menu.SQL.Text:='Select * From "tblMenus"';
dbQuery_Menu.Open;
the exception is triggered when the OPEN statement gets executed.
BTW, dbQuery_Menu is defined as a TSQLQuery component.
Clueless! :(
Run error 211 appears when you try to call an abstract method. Check this link from more information on FreePascal/Lazarus runtime errors.
Since you say all is done by code and you have no visual components, the problem probably lies in your code trying to use an ancestor component which has not overriden the Open method. You should be able to solve this by using the correct descendant component.
Another possibility, although I would strongly recommend to avoid this one, is to override the Open method yourself. It should be avoided because if you are using an ancestor component then you probably would have to override more abstract methods.
HTH
After nearly 5 days I found the answer. Many thanks to all thos e ho have contributed with their ideas ESPECIALLY RRUZ, RBA and Guillem Vicens. there are other related posts all connected to getting the FIRST Lazarus program working with PostgreSQL.
Summary.
The biggest mistake I made here was that I used the TSQLConnection component. Don't do this. Instead use the TPQConnection.
Everything is done through code. We're not using any draggable components from the top tab.
Don't rely on the Lazarus docs (wiki) at least for working with PG DBs.. It is outdated. Some of the examples can be pretty misleading.
Make sure that fields have some default values. For example, if a Boolean field has no true or false (t/f) set, this may lead to errors.
And that's it! I hope many postgres+Lazarus newbies will find this useful.
From here - http://www.network-theory.co.uk/docs/postgresql9/vol2/SQLSTATEvsSQLCODE.html - -211 (ECPG_CONVERT_BOOL) This means the host variable is of type bool and the datum in the database is neither 't' nor 'f'. (SQLSTATE 42804)
I'm getting an error when I'm trying to replace a GoTo in a while loop with a Continue, but whenever I do I get an error reading "Statement expected, but expression of type 'Boolean' found". Is continue a keyword not in Delphi 6? Does the error message mean something else?
Thanks.
It is in Delphi 5, so I would assume it is in Delphi 6.
There must be something else going on in your code, but without posting it, it's impossible to tell.
The error message means that somebody gave a variable the same name as the keyword and Delphi is using that instead of the keyword. Find the variable and try renaming it.
I'm trying to get rid of some hints(*) the Delphi compiler emits. Browsing through the ToolsAPI I see a IOTAToolsFilter that looks like it might help me accomplish this through it's Notifier, but I'm not sure how to invoke this (through what xxxServices I can access the filter).
Can anyone tell me if I´m on the right track here? Thanks!
(*) In particular, H2365 about overridden methods not matching the case of the parent. Not so nice when you have about 5 million lines of active code with a slightly different code convention than Embarcadero's. We've been working without hints for months now, and we kinda miss 'm. :-)
Even if you could query BorlandIDEServices for IOTAToolsFilter, that interface isn't going to help you do what you're asking. That interface was introduced as part of a mechanism for adding additional build tools (compilers, etc.) to the IDE (before the IDE used MSBuild). It allowed you to write a custom "filter" to handle output from a particular build tool, but it would not let you apply a filter to one of the built-in tools (like the delphi compiler).
The reason the Supports(BorlandIDEServices, IOTAToolsFilter, OTAToolsFilter) call fails in Delphi2010 is that once MSBuild support was added to the IDE, the old way of adding build tools to the IDE was disabled, and the BorlandIDEServices interface no longer supported IOTAToolsFilter.
The declaration of IOTAToolsFilter should probably have been marked deprecated in ToolsAPI.pas (or least it should have been mentioned in the source code comment that it is no longer supported).
As far as your desire to filter a particular hint, I'm not aware of a way to do that via the ToolsAPI. It seems like a reasonable thing that can be added to IOTAMessageServices (the ability to enumerate, filter, and possibly change the messages in the IDE's Message View). I would enter a request in QualityCentral for that.
Also, please vote for QC #35774 (http://qc.embarcadero.com/wc/qcmain.aspx?d=35774), as if that were implemented, you would not need to use the ToolsAPI for this sort of thing.
According to http://docwiki.embarcadero.com/RADStudio/en/Obtaining_Tools_API_Services it should be possible to access it directly using BorlandIDEServices, eg:
var
OTAToolsFilter: IOTAToolsFilter;
begin
if Supports(BorlandIDEServices, IOTAToolsFilter, OTAToolsFilter) then
ShowMessage('supports IOTAToolsFilter')
else
ShowMessage('IOTAToolsFilter NOT supported');
end;
However this doesn't return the desired interface in Delphi 2010 (you'll get the not supported message), so there's either an error in the documentation, or an error in BorlandIDEServices not returning the correct interface.