Closed Thread
Page 5 of 5 FirstFirst ... 345
Results 41 to 46 of 46

Thread: How to get floppy disk information ?!!

  1. #41
    dinklebaga is offline Newbie
    Join Date
    Mar 2009
    Posts
    23
    Rep Power
    0

    Re: How to get floppy disk information ?!!

    dargueta I'm struggling to get the program to write the sector back to the disk once it has found the correct amount of slack. I'm not too familiar with C++ but when i'm using WriteFile with the same parameters as the ReadFile operation (which is working) before it's failing to write and going into the "Cannot write slack" loop. Can you spot anything immediate?

    Code:
    dwBytesRead = 0;
    				if(!WriteFile(hDrive, memsectptr, clustersize, &dwBytesRead, NULL))
    				{
    					printf("Error writing to slack\n");
    					return 0;
    				}
    				//WriteFile(hDrive, memsectptr, clustersize, &dwBytesRead, NULL);
    				printf("Operation Successful\n");
    				printf("Stored in logical sector: %d\n", clustercount);
    				printf("Slacksize = %d\n", slacksize);
    				filesize = 0;

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #42
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: How to get floppy disk information ?!!

    EDIT: Try using this function in your error catching code. Requires windows.h.
    Code:
    void printWinError(void)
    {
    	DWORD dwError = GetLastError();
    	char *pszMessage = NULL;
    	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, /*options*/
    				NULL, /*message source, don't need for our purposes here*/
    				dwError, /*error code whose corresponding message we want*/
    				0, /*use default language*/
    				(LPVOID)&pszMessage, /*pointer to the buffer receiving the message*/
    				1, /*minimum number of bytes to allocate*/
    				NULL); /*extra arguments*/
    	printf("ERROR %08X: %s\n",dwError,pszMessage);
    	LocalFree(pszMessage);
    }
    If you're using this on the C: drive it won't work. Windows will block you.

  4. #43
    dinklebaga is offline Newbie
    Join Date
    Mar 2009
    Posts
    23
    Rep Power
    0

    Re: How to get floppy disk information ?!!

    I've added this code into the stdafx.h header file but i'm getting the following error message on compile:

    error C2664: 'FormatMessageW' : cannot convert parameter 5 from 'LPVOID' to 'LPWSTR'
    1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast

  5. #44
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: How to get floppy disk information ?!!

    Oooh, my bad. Replace the typecast LPVOID with LPWSTR and change pszMessage from char to wchar_t. Also, capitalize the s in printf.

    It should now look like this:
    Code:
    void printWinError(void)
    {
    	DWORD dwError = GetLastError();
    	wchar_t *pszMessage = NULL;
    	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, /*options*/
    				NULL, /*message source, don't need for our purposes here*/
    				dwError, /*error code whose corresponding message we want*/
    				0, /*use default language*/
    				(LPWSTR)&pszMessage, /*pointer to the buffer receiving the message*/
    				1, /*minimum number of bytes to allocate*/
    				NULL); /*extra arguments*/
    	printf("ERROR %08X: %S\n",dwError,pszMessage);
    	LocalFree(pszMessage);
    }

  6. #45
    dinklebaga is offline Newbie
    Join Date
    Mar 2009
    Posts
    23
    Rep Power
    0

    Re: How to get floppy disk information ?!!

    Cheers,
    Found out the problem I was having was because I hadn't opened the disk in read/write mode, only read (numpty)

  7. #46
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: How to get floppy disk information ?!!

    Yeah, that'll do it.

Closed Thread
Page 5 of 5 FirstFirst ... 345

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Loose disk??
    By bbqroast in forum Technology Ramble
    Replies: 3
    Last Post: 10-16-2010, 11:37 PM
  2. Disk Failure
    By lor in forum The Lounge
    Replies: 15
    Last Post: 10-08-2010, 03:24 AM
  3. Floppy DUO | Metallica - Fade To Back
    By Turk4n in forum The Lounge
    Replies: 10
    Last Post: 05-04-2009, 04:19 PM
  4. Compilers that fit on floppy?
    By jayrare in forum General Programming
    Replies: 24
    Last Post: 07-03-2008, 07:37 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts