2 Replies - 590 Views - Last Post: 12 October 2012 - 04:36 AM

#1 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

whats wrong in that code

Posted 11 October 2012 - 11:41 PM

when i try to open a txt file, the file is openend in a richedit, but there are some wrong chars after the file.
I mean when the text inside a txt is `12345`, then output in the editbox is `12345;/~/`

so my ask is what is wrong here in this code

.data
NamePathBuffer	db	265 dup (0)

.data?
hFile				DWORD		? 
-------

Open_File Proc hWin:DWORD, id_edit:UINT, buf:DWORD, buf_size:DWORD ,nFileSize : DWORD,hMem :DWORD


	invoke RtlZeroMemory, Addr buf, SIZEOF buf
	invoke RtlZeroMemory, Addr hMem, SIZEOF hMem
	invoke RtlZeroMemory, Addr hFile, SIZEOF hFile
	invoke RtlZeroMemory, Addr nFileSize, SIZEOF nFileSize
	invoke RtlZeroMemory, Addr NamePathBuffer, SIZEOF NamePathBuffer
	invoke RtlZeroMemory, Addr buf_size, SIZEOF buf_size

	invoke GetOpenFileName, Offset OFNstruc
		.if eax== TRUE
			invoke CreateFile, addr NamePathBuffer,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,NULL,NULL
				.if eax == -1
					Call GetLastError
						.if eax == ERROR_FILE_NOT_FOUND
							invoke MessageBox, NULL, Addr Message, Addr Message, MB_OK
						.elseif eax == ERROR_ACCESS_DENIED
							invoke MessageBox, NULL, Addr Message2, Addr Message2, MB_OK
						.endif
				.endif
			mov	hFile,eax
			invoke GetFileSize, hFile, NULL
			mov nFileSize, eax
			invoke GlobalAlloc,GPTR, nFileSize
			mov hMem,eax
			push	NULL
			mov	eax,esp
			invoke ReadFile,hFile,hMem,nFileSize,eax, NULL
			pop eax
			invoke CloseHandle,hFile
			invoke SetDlgItemText, hWin,id_edit, hMem
			invoke GlobalFree, hMem
		.endif
			invoke RtlZeroMemory, Addr buf, SIZEOF buf
	ret
Open_File endp



This post has been edited by Latias: 11 October 2012 - 11:47 PM


Is This A Good Question/Topic? 0
  • +

Replies To: whats wrong in that code

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,287
  • Joined: 28-March 11

Re: whats wrong in that code

Posted 12 October 2012 - 04:30 AM

I split one of your questions where you posted this originally, the answer is here: www.dreamincode.net/forums/topic/295253-problem-with-readfile/
Was This Post Helpful? 0
  • +
  • -

#3 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

Re: whats wrong in that code

Posted 12 October 2012 - 04:36 AM

oh i thought you delete it.
well now please you can remove this topic
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1