Bob
Bob

Reputation: 707

Using _set_invalid_parameter_handler in Delphi

Does anyone know how to use _set_invalid_parameter_handler with Delphi XE7 or later? See MSDN Article

Oops, it seems I should probably have given more context. I'm trying to load a C DLL that wraps a Matlab-based DLL. This worked before when I was using Delphi 2007, but fails now with XE7. I get these messages in the Event Log:

Module Load: RunChecker.dll. No Debug Info. Base Address: $10000000. Process myapp.exe (12304)
Module Load: libRunChecker.dll. No Debug Info. Base Address: $02A30000. Process myapp.exe (12304)
Module Load: mclmcrrt7_17.dll. No Debug Info. Base Address: $02A40000. Process myapp.exe (12304)
Module Load: PSAPI.DLL. No Debug Info. Base Address: $75420000. Process myapp.exe (12304)
Debug Output:
Invalid parameter passed to C runtime function.

Process myapp.exe (12304)
Debug Output:
Invalid parameter passed to C runtime function.

Process myapp.exe (12304)
Debug Output:
Invalid parameter passed to C runtime function.

Process myapp.exe (12304)
Debug Output:
Invalid parameter passed to C runtime function.

Process myapp.exe (12304)
Debug Output:
Invalid parameter passed to C runtime function.

Process myapp.exe (12304)
Debug Output:
Invalid parameter passed to C runtime function.

Process myapp.exe (12304)
Thread Start: Thread ID: 7192. Process myapp.exe (12304)

I'm trying to figure out what is causing these errors, and my search led to the above, but perhaps it is wrong? But I'm trying to get some insight into where the failure is introduced. Any thoughts/suggestions most appreciated!

Upvotes: 1

Views: 306

Answers (1)

David Heffernan
David Heffernan

Reputation: 613013

_set_invalid_parameter_handler is part of the MSVC runtime. It's not something that you call directly from Delphi code because your Delphi code doesn't link to the MSVC runtime.

If you do wish to call _set_invalid_parameter_handler you should do so from the code that links to the MSVC runtime. In your case that would be your C DLL.

All that said, almost certainly the problem relates to the Char and PChar types. In Delphi 2007 they are aliases to AnsiChar and PAnsiChar respectively. In Delphi 2009 and later they are aliases to WideChar and PWideChar respectively.

Upvotes: 1

Related Questions