[fpc-pascal] mmsystem unit : errors
Michael Van Canneyt
michael at freepascal.org
Wed Aug 3 09:33:26 CEST 2005
On Wed, 3 Aug 2005, Jean-Marc Chourot wrote:
> Hi all,
> Could someone help to understand what happens with this piece of code :
> When I call the following function, I very very often receive an error
> :MCIERR_PARAM_OVERFLOW: writeln(err,' The output string was not long
> enough.');
> Does anybody know why ? why is the pchar too small ?
> thx for help
> JM
>
>
> function SendMCIString2(cmd :PChar) :pchar;
> var x: hwnd;
> a:pchar ;
> l:integer;
> err:dword;
> begin
> err:= mciSendString(cmd, a, Sizeof(a), x);
This is definitely wrong, sizeof(a) is the size of the pointer a = 4.
Normally, based on my experience with the windows APIs,
I would also expect that you must allocate a buffer, and have 'a' point to it.
So something like
bufSize:=1024;
a:=getmem(bufsize);
err:= mciSendString(cmd, a, bufsize, x);
But that is just a guess, I don't know what mcisendstring is supposed to do.
Michael.
> if err=0 then
> result:= a
> else begin
> case err of
> MCIERR_BAD_CONSTANT: writeln('The value specified for a parameter is
> unknown.');
> MCIERR_BAD_INTEGER:writeln(' An integer in the command was invalid or
> missing.');
> MCIERR_DUPLICATE_FLAGS: writeln('A flag or value was specified twice.');
> MCIERR_MISSING_COMMAND_STRING:writeln(' No command was specified.');
> MCIERR_MISSING_DEVICE_NAME:writeln(' No device name was specified. ');
> MCIERR_MISSING_STRING_ARGUMENT:writeln(' A string value was missing from the
> command.');
> MCIERR_NEW_REQUIRES_ALIAS:writeln(' An alias must be used with the "new"
> device name.');
> MCIERR_NO_CLOSING_QUOTE: writeln('A closing quotation mark is missing.');
> MCIERR_NOTIFY_ON_AUTO_OPEN :writeln('The "notify" flag is illegal with
> auto-open.');
> MCIERR_PARAM_OVERFLOW: writeln(err,' The output string was not long
> enough.');
> MCIERR_PARSER_INTERNAL:writeln(' An internal parser error occurred.');
> MCIERR_UNRECOGNIZED_KEYWORD:writeln(' An unknown command parameter was
> specified.');
> MCIERR_BAD_TIME_FORMAT:writeln(' The specified value for the time format is
> invalid.') ;
> MCIERR_CANNOT_LOAD_DRIVER:writeln(' The specified device driver will not
> load properly.');
> MCIERR_CANNOT_USE_ALL:writeln(' The device name "all" is not allowed for
> this command.') ;
> MCIERR_CREATEWINDOW :writeln('Could not create or use window.');
> MCIERR_DEVICE_LENGTH:writeln(' The device or driver name is too long.
> Specify a device or driver name that is less than 79 characters.');
> MCIERR_DEVICE_LOCKED:writeln(' The device is now being closed. Wait a few
> seconds, then try again.');
> MCIERR_DEVICE_NOT_INSTALLED:writeln(' The specified device is not installed
> on the system. Use the Drivers option from the Control Panel to install the
> device.');
> MCIERR_DEVICE_NOT_READY:writeln(' The device driver is not ready.');
> MCIERR_DEVICE_OPEN :writeln('The device name is already used as an alias by
> this application. Use a unique alias.');
> MCIERR_DEVICE_ORD_LENGTH:writeln(' The device or driver name is too long.
> Specify a device or driver name that is less than 79 characters.');
> MCIERR_DEVICE_TYPE_REQUIRED:writeln(' The specified device cannot be found
> on the system. Check that the device is installed and the device name is
> spelled correctly.');
> MCIERR_DRIVER:writeln(' The device driver exhibits a problem. Check with the
> device manufacturer about obtaining a new driver.');
> MCIERR_DRIVER_INTERNAL:writeln(' The device driver exhibits a problem. Check
> with the device manufacturer about obtaining a new driver.');
> MCIERR_DUPLICATE_ALIAS:writeln(' The specified alias is already used in this
> application. Use a unique alias.');
> MCIERR_EXTENSION_NOT_FOUND :writeln('The specified extension has no device
> type associated with it. Specify a device type.');
> MCIERR_EXTRA_CHARACTERS :writeln('You must enclose a string with quotation
> marks; characters following the closing quotation mark are not valid.');
> MCIERR_FILE_NOT_FOUND :writeln('The requested file was not found. Check that
> the path and filename are correct.');
> MCIERR_FILE_NOT_SAVED :writeln('The file was not saved. Make sure your
> system has sufficient disk space or has an intact network connection.');
> MCIERR_FILE_READ :writeln('A read from the file failed. Make sure the file
> is present on your system or that your system has an intact network
> connection.');
> MCIERR_FILE_WRITE:writeln(' A write to the file failed. Make sure your
> system has sufficient disk space or has an intact network connection.');
> MCIERR_FILENAME_REQUIRED :writeln('The filename is invalid. Make sure the
> filename is no longer than eight characters, followed by a period and an
> extension.');
> MCIERR_FLAGS_NOT_COMPATIBLE :writeln('The specified parameters cannot be
> used together.');
> MCIERR_GET_CD :writeln('The requested file OR MCI device was not found. Try
> changing directories or restarting your system.');
> MCIERR_HARDWARE :writeln('The specified device exhibits a problem. Check
> that the device is working correctly or contact the device manufacturer.');
> MCIERR_ILLEGAL_FOR_AUTO_OPEN :writeln('MCI will not perform the specified
> command on an automatically opened device. Wait until the device is closed,
> then try to perform the command.');
> MCIERR_INTERNAL :writeln('A problem occurred in initializing MCI. Try
> restarting the Windows operating system.');
> MCIERR_INVALID_DEVICE_ID:writeln(' Invalid device ID. Use the ID given to
> the device when the device was opened.');
> MCIERR_INVALID_DEVICE_NAME :writeln('The specified device is not open nor
> recognized by MCI.');
> MCIERR_INVALID_FILE:writeln(' The specified file cannot be played on the
> specified MCI device. The file may be corrupt or may use an incorrect file
> format.');
> MCIERR_MISSING_PARAMETER:writeln(' The specified command requires a
> parameter, which you must supply.');
> MCIERR_MULTIPLE:writeln(' Errors occurred in more than one device. Specify
> each command and device separately to identify the devices causing the
> errors.');
> MCIERR_MUST_USE_SHAREABLE :writeln('The device driver is already in use. You
> must specify the "shareable" parameter with each open command to share the
> device.');
> MCIERR_NO_ELEMENT_ALLOWED:writeln(' The specified device does not use a
> filename.');
> MCIERR_NO_INTEGER :writeln('The parameter for this MCI command must be an
> integer value.');
> MCIERR_NO_WINDOW :writeln('There is no display window.');
> MCIERR_NONAPPLICABLE_FUNCTION :writeln('The specified MCI command sequence
> cannot be performed in the given order. Correct the command sequence; then,
> try again.');
> MCIERR_NULL_PARAMETER_BLOCK :writeln('A null parameter block (structure) was
> passed to MCI.');
> MCIERR_OUT_OF_MEMORY :writeln('Your system does not have enough memory for
> this task. Quit one or more applications to increase the available memory,
> then, try to perform the task again.');
> MCIERR_OUTOFRANGE :writeln('The specified parameter value is out of range
> for the specified MCI command.');
> MCIERR_SET_CD :writeln('The specified file or MCI device is inaccessible
> because the application cannot change directories.');
> MCIERR_SET_DRIVE :writeln('The specified file or MCI device is inaccessible
> because the application cannot change drives.');
> MCIERR_UNNAMED_RESOURCE :writeln('You cannot store an unnamed file. Specify
> a filename.');
> MCIERR_UNRECOGNIZED_COMMAND :writeln('The driver cannot recognize the
> specified command.');
> MCIERR_UNSUPPORTED_FUNCTION :writeln(' Unsupported function');
> else writeln('unknownerror');
> end;
>
> result:='';
> end;
>
> end;
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list