Autorun - How?

This is a discussion on Autorun - How? within the C++ Programming forums, part of the General Programming Boards category; The code compiles in Dev-C++, Visual C++ and LCC-WIN32. I don't know the library system that Borland uses but try ...

  1. #16
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The code compiles in Dev-C++, Visual C++ and LCC-WIN32. I don't know the library system that Borland uses but try getting rid of all the "#pragma comment(lib, ...)" lines and using import32.lib instead.

  2. #17
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    Ya, my bad, I was just being dumb. Sry. How do I get a .CPP file to compile with a .c file? It cann't find the function, and if I put a prototype up, it says Undeclared external sonthing morother. So i'm trying to build a DLL, but since i've never built one, its going slowly!

    i get an error here:
    Code:
    extern "C" __declspec(dllexport)BOOL xAddSelfAsStartupShortcut(LPCTSTR szLinkTitle, LPCTSTR szDescription,
                                   LPCTSTR szArguments, int IconResourceID);
    DW

  3. #18
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Here is the Dev-C++ project. I don't know the details of the Borland compiler but I would check if it supports __declspec(dllexport). You should be able to just add the .c file to your project. Good pickup on the extern "C", which was missing.
    Attached Files Attached Files

  4. #19
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    I gave up on the DLL. I just got it to work with the extern "c" part. I can't believe i forgot it. I'll post the BCB project incase anyone needs it.

    I have a question though, how do you remove it?

    DW
    Attached Files Attached Files

  5. #20
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Code:
    BOOL xDeleteSelfAsStartupShortcut(LPCTSTR szLinkTitle)
    {
    	TCHAR szLinkName[MAX_PATH + MAX_PATH + 10];
    
    	if (FAILED(xGetFolderPath(szLinkName, CSIDL_STARTUP)))
    	{
    		return FALSE;
    	}
    
    	lstrcat(szLinkName, TEXT("\\"));
    	lstrcat(szLinkName, szLinkTitle);
    	lstrcat(szLinkName, TEXT(".lnk"));
    
    	return DeleteFile(szLinkName);
    }

  6. #21
    Registered User
    Join Date
    Jun 2004
    Posts
    20
    "How is as such: add it(the .c file) to your project through Project-> Add to project, then add the function prototype, and Voila, it should work. Fix the linker stuff, and your good to go."

    - "the .c file" hmm. Can I just create this manually to "My projects" -folder? 'Cause I really didn't understand the above, except for the linker -part.

    Or can you attach "the .c file" to this forum so I can just download it and add it to "My projects" -folder?

    Thanks for any assistance.

  7. #22
    Registered User
    Join Date
    Jun 2004
    Posts
    20
    Huh, didn't even notice there was a second page.

    Well, so. I'll try to work something out but I still prob. need an attached project with the autorun and then I'll just edit it.

  8. #23
    Registered User
    Join Date
    Jun 2004
    Posts
    20
    "need an attached project with the autorun and then I'll just edit it."

    Yep, tried everything. So can somebody attach a project here which is a "complete example" that includes the whole project with an application of your own, and then I'll just change the application code and phuff. :>

  9. #24
    Registered User
    Join Date
    Jun 2004
    Posts
    20
    Getting an error from this line in Dev-C++:

    hres = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (void **) &psl);

    Reason:

    71 C:\Program Files\Dev-C++\My Projects\AutoRun.c
    could not convert `&CLSID_ShellLink' to `const CLSID&'

    So what to do?

  10. #25
    Registered User
    Join Date
    Jun 2004
    Posts
    20
    Alright, now I've done it with Borland. But I only have the autostartup, so how can i add my program there?

    And i want to take that "add"/"exit" off.

    I just want one program, and when started, it will first put a shortcut to StartUp, and then it will just open my own program.

    I mean i want this shortcut-thing to be so-called function, and the main program is my program.

    So how can I do this with borland?

  11. #26
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    5 concutive post! OMG! I think you beat my record! lol

    I have a deal for you. What compiler are you using? Dev-C++ or Borland C++ Builder? If you send me your project, add it for you. PM me..

    DW

  12. #27
    Registered User
    Join Date
    Jun 2004
    Posts
    20
    Uh, huh, buuh. This forum is way too complicated for built/help instructions.

    Come to IRC(internet relay chat) on Quakenet, channel: #bleehbleeh

    If you do not have irc, we could also go to somekind of a chat on web.

  13. #28
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    How do I get this too work in dev-c++? I really don't have much experiance with it. It works fine in BCB.....

    I add the .c file, add '-lole32 -luuid -lshell32' to the linker parameters, then extern "C" it.

    i get a linker error as such:Fatal E:\MyDocs\Chris\AutoRun Example\Fatal
    'all-before' does not exist - don't know how to make it

    cheers

    DW

    PS: that removal code works fine too! thx!

  14. #29
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by nouneim
    And i want to take that "add"/"exit" off.
    Not to be harsh, but if you don't understand how to remove the yes/no question from the example program then this is way too advanced for you and you should go back into studying if-statements.
    Quote Originally Posted by nouneim
    Uh, huh, buuh. This forum is way too complicated for built/help instructions...
    Heh.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  15. #30
    Registered User
    Join Date
    Jun 2004
    Posts
    20
    "Not to be harsh, but if you don't understand how to remove the yes/no question from the example program then this is way too advanced for you and you should go back into studying if-statements."

    To be exact, I compiled the program with BCB, which I had never used before, so I couldn't even get in touch with the file that had the code.

    And maybe so, maybe I am a newbie, yet the best way to learn is to get a code and start editing it and look the commands from a c++ -book, which is a bit more difficult for me 'cause the book I have is finnish-translated and all the examples are in finnish. Also I have never before had in touch with system-settings nor anything like it.

    But what am I defending myself for? So then I am a newbie, ohmigosh.

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows virus?
    By cyberfish in forum A Brief History of Cprogramming.com
    Replies: 99
    Last Post: 07-20-2008, 06:46 AM
  2. USB Card Autorun
    By Junior89 in forum Tech Board
    Replies: 1
    Last Post: 11-07-2004, 10:06 AM
  3. USB Autorun
    By Glirk Dient in forum Tech Board
    Replies: 2
    Last Post: 11-13-2003, 07:04 AM
  4. autorun app
    By ober in forum C++ Programming
    Replies: 8
    Last Post: 04-02-2003, 12:48 PM
  5. text files and autorun?
    By ukcpaul in forum Windows Programming
    Replies: 4
    Last Post: 03-15-2002, 04:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21