Could someone please place a source for COPYING files, DELETING Files, MOVING files, and RENAMING files. I would like the code to be without a dialogbox, and to do the job automatically. I am particularly interested in the RENAMING of files using NO dialogbox or GUI. Just the straight job.

Thank-you
Posted on 2001-09-28 18:54:12 by SpEcIeS
sPeCiEs,

This capacity already exists in the windows API functions, all you need to do is bother to look them up and write the code. Windows has some very powerful capacity in file manipulation so it is worth the effort to learn this stuff.

Regards,

hutch@pbq.com.au
Posted on 2001-09-28 19:00:52 by hutch--
Perhaps I did not make myself clear enough. I want to compare and improve the procs that I already have. Possibly making my procs samller and faster. However, I am not sure how to rename files, without GUI, in win32. It is unclear to me. This is all that is needed.
In the future, maybe you would preferr to save your assumsions, and ask more questions if something is unclear. Is this not the purpose of this messageboard ?






Reply:

This capacity already exists in the windows API functions, all you need to do is bother to look them up and write the code. Windows has some very powerful capacity in file manipulation so it is worth the effort to learn this stuff.
Posted on 2001-09-28 23:04:43 by SpEcIeS
delete file = DeleteFile api.

rename file = MoveFile. This can also be used for (limited!) moving
of files or directories, *within the same partition*.

Copying file? Well, you can use CopyFile, or you can open the two
files yourself and do the copy.

*really* move a file (across partitions) is a copy and a delete.

There's no real reason to "optimize" these routines. It's hard to get
them faster... sure, if you have a really lame copy file routine, but...
Posted on 2001-09-28 23:31:52 by f0dder
sPeCiEs,

==================
In the future, maybe you would preferr to save your assumsions, and ask more questions if something is unclear. Is this not the purpose of this messageboard ?
==================

My assumptions are based on what you say, this forum is not a code ordering facility, its members help other members without any imperative or obligation. When you respect that and are willing to learn, you will do OK.

I in fact told you the truth, the win32 API functions for file IO are very powerful and all you need to do is look them up and you will be able to do all of what you asked and many more things as well.

If you have some questions, feel free to ask them as there are many experienced programers here but you can forget treating the forum like a facility that supplies code for you. No-one has any obligation to complie with requests.

Regards,

hutch@pbq.com.au
Posted on 2001-09-29 07:47:51 by hutch--
First of all I would like to thank f0dder for the decent reply, and with the limited information. I think I know what to do. The obvious API's are know to me, but I just wanted to view other code to compare... such as:

.386
.model flat,stdcall
option casemap:none

MainFunction PROTO

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data?
FHandle dd ?
NumBytesWritten dd ?
Bytes dd ?
FileBuff db 10 dup(?)

.data
TextTxt db "text.txt",0
ReceiveDat db "receive.dat",0
NewFileNameTxt db "NewFileName.txt",0
Data db "This is data....",0

.code
start:

invoke MainFunction
invoke ExitProcess,eax

MainFunction proc
;Create RECEIVE.DAT
invoke CreateFile,addr ReceiveDat,GENERIC_READ,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
mov FHandle,eax
invoke CloseHandle,FHandle

;Create TEXT.TXT with Data
invoke CreateFile,addr TextTxt,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
mov FHandle,eax
invoke WriteFile,FHandle,addr Data,16,addr NumBytesWritten,0
invoke CloseHandle,FHandle

;Read TEXT.TXT
invoke CreateFile, ADDR TextTxt, GENERIC_READ, 0, 0,OPEN_EXISTING, 0, 0
mov FHandle, eax
invoke GetFileSize,FHandle,NULL
mov Bytes,eax
invoke ReadFile, FHandle, ADDR FileBuff,Bytes, ADDR NumBytesWritten, 0
invoke CloseHandle,FHandle

;Create RECEIVE.DAT
invoke CreateFile,addr ReceiveDat,GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
mov FHandle,eax
invoke WriteFile,FHandle,addr FileBuff,Bytes,addr NumBytesWritten,0
invoke CloseHandle,FHandle

ret
MainFunction endp

end start

(This is also placed to show that I am not interested in leeching code as hutch implys)

I was just unclear as to the renaming of files. I did have a, what I call, long version(MOVING FILES), but I felt that there must have been a better way. Sometimes it is good to ask questions. Thanks again f0dder.

As for hutch, the truth was never said by you, and the only interest that came from you, yet again, is the blind statements revolving around leeching code. As for the any imperative or obligation statement, you really should try and be a little less paranoid. This is a place to LEARN is it not? You are of no help to this LEARNING experience, and I would appreciate if only serious people reply to my question. If all you want to do is complain and point the finger, well ... I just hope you can grow out of it and really try and answer the questions at hand. I mean REALLY. On all of the other messages there is free flowing information and SAMPLE CODE to help along. This is what I saw and understood it as. Not for a moment did I think that someone would be casting uneducated stones at people. It is easy to be a critic, however it is very hard to be an effective tutor.

Thank-you
Posted on 2001-09-29 08:23:48 by SpEcIeS
I'm am sure the Hutch is under a lot of preasure trying to help everyone while at the same time rewriting masm32. I get mad at the way he answer some questions sometimes too, but hell, if we were doing what these educators do for us DAY and NIGHT someone is sure to crack. No way am I running to anyone rescuse, because the dust could come down on me. While trying to crack a few thing about Windows it almost craked me twice. It's time for us to start taking it easy so the we all can get things done right... By the way thank God someone explain how to do it, I bend tring to figure it out for over 9 months now it was about to get an handle on it.

SMILE AND BE HAPPY ... i am
Posted on 2001-09-29 10:24:11 by Unregistered
sPeCiEs,

If you cannot see what you have done, you have some to learn in dealing with people. This forum is made up of members who contribute what they can, answer what questions they know and generally help out where they can.

The tinge of arrogance in your original post that someone is obliged to write code for you is misplaced. Many of the programmers here write code for a living and I am sure they could give you a price for the work you requested but be clear that no-one "owes" their time and effort to you.

If you have questions to ask, feel free to do so but spare us the code ordering arrogance, there are many other places on the net where commerce can take place but this is not one of them, this is a forum of members who co-operate in a friendly way and help who they can.

Unregistered,

Thanks for the plug but have no fear, being cantankerous and ancient at the same time makes you pretty robust. :tongue:

Regards,

hutch@pbq.com.au
Posted on 2001-09-29 10:58:59 by hutch--
You just do not seem to get it. I DID NOT ASK FOR YOUR HELP!!! I simply asked for help. NOT YOUR HELP OR ANYONE ELSE THAT IS ARROGANT LIKE YOU!
I was simply trying to find out information. Plain and simply. I do NOT feel that anyone OWES me the time to code. Only the people who WANT to contribute to this post. If YOU did not want to reply constructively why did you even bother?
The purpose of a message board such as this, I thought, was to learn and move on in skills. Not ONE person is obligated to respond to posts. Only the individuals that would like to contribute THIER time and code. Not too complex.
There was no demand placed in my post, or not to my knowledge.

THANK-YOU
Posted on 2001-09-29 11:19:39 by SpEcIeS
SpEcIeS, Hutch is not really like you said.
He answered my questions in this forum in a very clearly way, as well he helped lots of others. I never read ANY arrogant post from him.

Yes, the point of this messageboard is to learn... if Hutch is really like you say, i don't think he would ever have released his masm32 package (without it, i'm sure many people would have given up) and many other things like Sort procs.

Your original post asked more or less explictly source code.
Many people here post source code that they think useful to the community.
But as a coder, it's your part of work to search a bit before to post a question on sites like MSDN, CHM files from Platform SDK win32.hlp or Iczelion's tutorials.

Asking questions is not a problem... many people here are very kind to newbies and really want to help... but everyone here respect each other and no one will break this rule.

Now, no bad feeling, and don't hesitate to post again if you have questions ;)
Posted on 2001-09-29 13:07:36 by JCP
Don't be so rude, species, or you'll end up with nobody wanting to
help you. If you bother to do a little research of your own before
posting, people will be friendlier and more helpful. That way, people
will have more time to answer more interesting questions...

Using MSDN or the like is not hard. platform sdk-> windows base services -> files and I/O -> file I/O ...
not too hard to look up, imho.

I don't mean to sound like an elitistic prick, just throwing in a few
reasonable words, imho. This messageboard should be a friendly
place, and I don't think your previous posts were.

Peace.
Posted on 2001-09-30 10:44:59 by f0dder
This is the last I will be replying to this BS.

I am starting to get a little tired of all this kiss ass and echoing. I DID do some research, and if any of you BOTHERED you would have noted that I said PLEASE in the first message. This does not INDICATE a demand.. DUH! As for help, well I received very little help, and mostly critisizm. It was just a simply question, and this is what I get.. whatever... <???> Perhaps you would like to critise Hutch. I did not really see much of that; after all he did make the first stab at assuming that I did not do any research.

I hope that the code that I posted here helps a lot of people, and I could place more code in the future. But I will not be helping anyone if this kind of juvenille treatment continues. Not to say that I am the greatest programmer, but if someone wants help and I have the time and answer, I will do so.

Perhaps I was wrong to assume that the message board was to be used in this friendly and helpful way. I did not KNOW that there was some underlying secrect way to respond to the message board, and people are ready to pounce like drunken lions on a dead mouse at every word. Very, very desperate......:(

Anyway, Hutch I am sorry for doing WHATEVER it is I did, or what you think I did. As for the individuals grovelling at your feet, for whatever reason. Keep it up BOYS your nose is getting browner.

So in closing, I will not be replying anymore to this message. If one wants to deal with this in the future SO BE IT. Pick and bad mouth away, and I hope that it fills your life with happiness.



THANK-YOU

;)
Posted on 2001-10-01 09:18:09 by SpEcIeS

This is the last I will be replying to this BS.


Even if you don't reply to this post, i hope you will read it in order to understand our reactions.

I DID do some research


How that ?
Iczelion's tutorials are on this Messageboard and explains a lot about file handling on win32 systems...
Did you seriously check your win32 api documentation ?
These API are very common. It's why we told you to search a bit more.

I hope that the code that I posted here helps a lot of people, and I could place more code in the future.
.

That's a good attitude.

But I will not be helping anyone if this kind of juvenille treatment continues.


Isn't this reaction juvenile ?

Perhaps I was wrong to assume that the message board was to be used in this friendly and helpful way. I did not KNOW that there was some underlying secrect way to respond to the message board, and people are ready to pounce like drunken lions on a dead mouse at every word. Very, very desperate......:(


Just look at the archives...
You will see that many people asking (sometimes very easy) questions have found a useful and friendly answer here.

Anyway, Hutch I am sorry for doing WHATEVER it is I did, or what you think I did. As for the individuals grovelling at your feet, for whatever reason. Keep it up BOYS your nose is getting browner.


Aren't you making any assumption there ? Or worse, insulting people ?
As many others, I am just thankful for what Hutch did.
I know if he didn't release great things like his MASM32 package and includes, I wouldn't be in win32asm programming right now. Even if i don't use QEditor anymore, it made my learning task lot easier.
I'm thankful to many others as well, not only to Hutch.

This messageboard is not hierarchical. What have i to say when people help me ? "Yeah, that's right, bye moron"... people here aren't really like this.


So in closing, I will not be replying anymore to this message. If one wants to deal with this in the future SO BE IT. Pick and bad mouth away, and I hope that it fills your life with happiness.


You can act as the victim in this affair, but no one has been fooled.
No one told you to run away from this MB... you're doing it from your own.
As I said in a previous post, you can come back when you want and ask questions (after having made some research, of course... and if you don't find, we will help you).
We aren't unforgiving.
Posted on 2001-10-01 11:34:39 by JCP
Could someone please place a source for COPYING files, DELETING Files, MOVING files, and RENAMING files. I would like the code to be without a dialogbox, and to do the job automatically. I am particularly interested in the RENAMING of files using NO dialogbox or GUI. Just the straight job.


I was personally offended just reading this before this mole-hill turned into a mountian.

Pesonally, i would be more than happy to provide ooodles of code and discussion (some find that i blabber too long in doing so), but on first read, all i could really think was... "Who does this guy think he is". Like someone is going to play your Coding-Monkey.

Im sure Hutch had simular feelings but decined them into just saying: "spend a moment and look them up".

The way your hiddind under this "i just want to learn" excuse is soooo lame. You were overly direct and a bit rude to assume we would jump to your beconing as if this was McDonalds, ready to hore ourselves to serve you better, with our personal concern for you to "learn".

Sorry Pal, ask for Help and you will recieve... with out discrimination. But demand "I would like.." and you can expect a fair bit of resentment and resistance.

Im personally surprised at Hutch's composure to be honest.

Nuff said, you can hate me too, i dont care... (but in the interest of helping you learn what your good at, i will give you a head start, you can pick on my spelling, i suck at it :rolleyes: )

NaN
Posted on 2001-10-01 16:38:12 by NaN
sPeCiEs,

=============================
This is the last I will be replying to this BS.
=============================

I am glad to see something profitable has come from this posting but the parting shots at some of the members of this forum are in bad taste.

I personally don't give a shit if you want to have a slice of me as I am robust enough for the occasional piece of stupidity but your comments on members here shows you have not got a clue when it comes to dealing with people.

Whether you know it or not, there are many very experienced programmers here who are doing advanced work and sharing it with other programmers yet no-one here suffers from the elitist bullshit that you have intimated.

Assembler was always plain old fashioned hard work and the people who do it don't have time for kiddies behaviour. What you seem to forget is that behind each name that posts here is a human being that has done a lot of work and shares it with others by means of goodwill.

We have heaps of young guys who are doing the hard stuff so when someone starts acting in an arrogant manner, they will get short shift from a number of people.

As you have made a clown of yourself under the nickname you have used, try coming back as another name and behave like a human being and you will do fine here. Thats what the forum is about, programmers helping other programmers.

Regards,

hutch@pbq.com.au
Posted on 2001-10-02 05:52:51 by hutch--
If I may ...
This section is about algorithms if I'm right.
So let old holy fight to judge who is right is the argue:
There is very simple task for programmers
those who first solve it is a winner and was right here.

Given:
1. Array of DWORDS
2. Size of the array

You need to find
1. the greatest common divider for all members
of the array.
2. To numbers X and Y so that
for any two numbers A & B in the array
GCD(greatest com divider) = A *x + B *y
(A >= B)
Posted on 2001-10-14 04:09:57 by The Svin
The Svin, I know I wasn't involved in this discussion but this is a nice problem so I thought I'd give it a try. I'm confused by the second part though.

As its stated there it won't always have a solution. For example with an array of nmber 3, 5 & 7 Whose GCD is 1 there are 3 equations:

1 = 7x + 5y
1 = 5x + 3y
1 = 7x + 3y

For the first two you get the solutions x = 0.5 and y = -0.5 but these don't work for the third problem. :confused:

The other possibility is that you mean, for any two numbers A & B from the array find two additional numbers x & y such that

GCD = Ax + By

However if this was the case I'm sure you'd have limited x and y to being integers as there's a very simple solution to the above problem when dealing with floats i.e. x = 0, y = GCD/B.

Or the third possibility is that this problem flew sthraight over my head and I'm missing something. :eek:
Posted on 2001-10-14 06:36:58 by Eóin
Right me again.

Ok problem 1. GCD of array:
.data

sAy dd 8
Ary dd 56,78,34,67,84,35,12,39
GCD dd ?
.code
mov esi,sAy
lea edi,Ary[-4]
mov eax,[edi][esi*4]
dec esi

lp: mov ecx,[edi][esi*4] ; ecx = b, eax = a
@@: xor edx,edx
div ecx
cmp edx,0
je @F
mov eax,ecx
mov ecx,edx
jmp @B
@@: mov eax,ecx
dec esi
jnz lp
mov GCD,eax

Just a note on the algo here. The algo is the Eucledian algo. For more info on it check this thread. When a & b are close Paul Hsieh's algo is about 20% fatser than a simple division one. However when dealing with an array you usually deal with one very small number and one potentially large one. The division method used above is then faster.

Of course an escape for when eax = 1 would speed things up greatly. And a second loop for when eax = 2 could be code efficiently also.

As for problem two, well if my second interpetation is correct and limiting to integers then the following will work:
; eax = GCD, ebx = A, ecx = B

; I.e. find x & y such that eax = (ebx)x + (ecx)y

lea edi,[ebx][eax]
sub edi,ecx
mov esi,1
@@: xor edx,edx
mov eax,edi
div ecx
cmp edx,0
je @F
inc esi
add edi,ebx
jmp @B
@@: inc eax
neg esi

; y = esi, x = eax
Posted on 2001-10-14 07:45:13 by Eóin
Well done!
The second task was kind of provocation :)
It has solution only with two numbers, not array > 2
But an expirience one in math could see it in a glance :)
So I just wished to know how many of (and how qweek)
could prove that second task simply has no solution for array > 2.
Posted on 2001-10-16 23:47:44 by The Svin