We help IT Professionals succeed at work.

Simple eVC Embedded Visual C++ code needed to assist beginner.

patricksd
patricksd asked
on
3,009 Views
Last Modified: 2013-12-27
I am a beginner and need the eVC code and supporting includes to perform the following tasks:

1) delete a specified file on the device.

2) check if a specified file exists on the device.

3) read a data value from a specified key in the registry.

4) write a data value to a specified key in the registry.

5) execute an external specified program which is a .cab file (installer).

6) exit the program when all tasks are completed. (I notice that even when I exit a simple "Hello World!" program, it is still running on the device. Why doesn't it shut itself down?)

I know many of these tasks can be performed with just a few lines of code, however, I am having trouble getting my code to compile/run and need an experts help. Thanks very much in advance.
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT

Commented:
CERTIFIED EXPERT

Commented:
How do you shut down your program? The following code should do it.

::AfxGetMainWnd()->PostMessage(WM_CLOSE);
CERTIFIED EXPERT

Commented:
CERTIFIED EXPERT

Commented:

Author

Commented:
Thanks for the quick response and pointing me in the right direction. Regarding checking if a file exists, could I just check the return value of CreateFile() to determine this?
CERTIFIED EXPERT

Commented:
void OpenFileExample (void)
{
  HANDLE hFile;

  hFile = CreateFile (TEXT("\\MYFILE.TXT"),   // Open MYFILE.TXT
                      GENERIC_READ,           // Open for reading
                      FILE_SHARE_READ,        // Share for reading
                      NULL,                   // No security
                      OPEN_EXISTING,          // Existing file only   ////// Right here and if doesnt exist youll get the error so yeah you can use it
                      FILE_ATTRIBUTE_NORMAL,  // Normal file
                      NULL);                  // No template file

  if (hFile == INVALID_HANDLE_VALUE)
  {
    // Your error-handling code goes here.
    return;
  }
} // End of OpenFileExample code

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.