473,320 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Different questions for C programming

Hello guys!
I'm new to this forum, this is my first post, so don't overreact if I do some mistakes.
I started C programming some days ago and now I have some questions I couldn't solve alone or with google. Maybe you could help me out!

1.
I got a problem with the function CopyFile(). In my program I'm using this line:
CopyFile("data.exe", "C:\\Windows\\system\\", FALSE);
It should copy the "data.exe" (which is in the same folder as the program itself). This compiles fine, without errors, but when I start the program the "data.exe" isn't copied! What do I do wrong? Oh and not to forget: I included the windows.h to use the CopyFile() function, that's not the problem.

2.
How can I edit the registry using some commands with my program?
I want to autostart a certain file when booting. Some friends told me that one option would be to just paste the file which is to be autostarted in the C:\Windows\Documents and Settings\All Users\Autostart folder, but they also said that this is the worse option. The better one would be to create an entry in the registry to autostart the file. How do I do this? What is the exact function/code to do this?

Sorry for my bad english, I tried my best!
Remember that I'm very new to C and programming in general, basically I'm just copying and pasting from others and not making any serious programs, so when you try to explain something, do it in easy words and don't assume that I already know all the basics.
I'm looking forward to your answers!
Regards,
Max
Oct 5 '07 #1
1 1341
weaknessforcats
9,208 Expert Mod 8TB
CopyFile("data.exe", "C:\\Windows\\system\\", FALSE);
A couple of things.
1) "data.exe" is not a file name. You should be calling GetFullPathName().

2) the arguments for CopyFile are LPCTSTR. That means that CopyFile is a macro that resolves to either CopyFileA or CopyFileW depending upon whether the character set is Unicode or not.

You should be including tchar.h and you code shoud use the TCHAR mappings:
CopyFile(TEXT("data.exe"), TEXT("C:\\Windows\\system\\data.exe"), FALSE);
As to the registry, please read this and be sure to follow the links.
Oct 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
18
by: Frankie | last post by:
I have been hired to go to a former client of mine and train their staff programmers on ASP.NET. These guys have only Mainframe, MS Access, SQL Server, and VB6 desktop application development...
23
by: Rick | last post by:
Hi, I'm currently preparing for an interview on VB.Net Development.. could someone please give me an idea as to what type of questions can one ask (it's a practical test) and what sort of things...
0
by: softwareengineer2006 | last post by:
All Interview Questions And Answers 10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP) I have listed over 10000 interview questions asked in interview/placement test papers for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.