LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Deletefile() in Labwindows CVI

32 should indicate a conflict with another process owning the file. See here.

Decoding SDK errors can be done by means of FormatMessage () function. In your case you could do something like this:

 

int		error;
char	buf[512];

if ((DeleteFile ("temp-txt")) == 0) {
	sprintf (buf, "%s %s %s:", DateStr (), TimeStr (), __FUNCTION__);
	// GetLastError + FormatMessage
	// DWORD WINAPI GetLastError(void);
	// DWORD WINAPI FormatMessage (
	//	__in          DWORD dwFlags,
	//	__in          LPCVOID lpSource,
	//	__in          DWORD dwMessageId,
	//	__in          DWORD dwLanguageId,
	//	__out         LPTSTR lpBuffer,
	//	__in          DWORD nSize,
	//	__in          va_list* Arguments
	//);
	error = GetLastError ();
	FormatMessage (
		FORMAT_MESSAGE_FROM_SYSTEM,	// __in  DWORD dwFlags,
		NULL,				// __in  LPCVOID lpSource,
		error,				// __in  DWORD dwMessageId,
		0,				// __in  DWORD dwLanguageId,
		buf + strlen (buf),		// __out LPTSTR lpBuffer,
		511 - strlen (buf),		// __in  DWORD nSize,
		NULL				// __in  va_list* Arguments
	);
	sprintf (buf, "%s (%d)", buf, error);
	// Show error message
	MessagePopup ("Error!", buf);
}

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 11 of 13
(1,279 Views)

I tried copying the code given by you and executed. It did not go into the function as Deletefile() is not returning zero. I had to remove the if() condition to make FormatMessage() work. 

However the problem is resolved now. The file was not closing properly. So I had to use one more fclose(). And to close the file I used remove(). And it is working fine now.

 

Thanks for the replies. 🙂

0 Kudos
Message 12 of 13
(1,275 Views)

As far as the conflict between the CVI and SDK versions of DeleteFile is concerned, you can always work around these collisions by setting the SDK_CONFLICT_PRIORITY macro.

0 Kudos
Message 13 of 13
(1,231 Views)