Ask for how to create & remove a shortcut on Vista

Hello guys! I'm a new comer~:)

I have a function to  create and remove a shortcut for my application
in my program. But it suffered some problem on Vista.

The problem is Vista need administrator's power to do what I need. If
I execute my program in administrator, it's OK. Else nothing happend
while my application trying to create shortcut, or popup the following
warning while my application trying to remove the shortcut:

	Access unnamed file is denied

I'm not familiar with Vista and program on Vista. So any kind
suggestion or information is welcome. I need your help!

Thank you very much

I used CFile::Remove to remove the shortcut and used following code to
create a shortcut:
*********************************************************
HRESULT CAutoStartSettingDlg::CreateShortcut(
		LPCTSTR pszLink,				// path of shortcut
		LPCTSTR pszFile,				// my application
		LPCTSTR pszDescription,	
		LPCTSTR pszArgs,			
		LPCTSTR pszWorkingDir,		// working directory
		LPCTSTR pszIconPath,
		int iIcon,				 		// icon index
		int iShowCmd)				// window style
{
    HRESULT hres;
    IShellLink *psl;

	CoInitialize(0);

    hres = CoCreateInstance(	CLSID_ShellLink, NULL, 					
								CLSCTX_INPROC_SERVER, 
								IID_IShellLink, (void **)&psl);
	if (SUCCEEDED(hres))
    {
		IPersistFile *ppf;

        hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
        if (SUCCEEDED(hres))
        {
			WORD wsz[MAX_PATH];

			psl->SetPath(pszFile);						// target file
			psl->SetDescription(pszDescription);	
			psl->SetArguments(pszArgs);
			psl->SetWorkingDirectory(pszWorkingDir);
			psl->SetIconLocation(pszIconPath, iIcon);	// icon
			psl->SetShowCmd(iShowCmd);				// window style

			MultiByteToWideChar(CP_ACP, 0, pszLink, -1, (LPWSTR)wsz,
MAX_PATH);

			hres = ppf->Save((LPCOLESTR)wsz, TRUE);

			ppf->Release();
        }

		psl->Release();
    }

	// Add by Junying Lee for 07A
	// To closes the OLE Component Object Model (COM) library
	CoUninitialize();
	// Add end

    return hres;
}
**********************************************************

Thank you very much again!!
0
Hitter
1/19/2007 4:57:16 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
387 Views

Similar Articles

[PageSpeed] 15

>I have a function to  create and remove a shortcut for my application
>in my program. But it suffered some problem on Vista.
>
>The problem is Vista need administrator's power to do what I need. If
>I execute my program in administrator, it's OK. Else nothing happend
>while my application trying to create shortcut, or popup the following
>warning while my application trying to remove the shortcut:
>
>	Access unnamed file is denied
>
>I'm not familiar with Vista and program on Vista. So any kind
>suggestion or information is welcome. I need your help!

If your application needs to run as the administrator it should have a
manifest resource to indicates this.

If you add the following information to any existing manifest file in
your project it will cause Vista to prompt appropriately to have your
application run as the administrator:

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator" uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>

For more information on the subject try Googling for the terms:
requestedExecutionLevel and requireAdministrator.

Dave
0
davidl7375 (2060)
1/21/2007 10:19:53 AM
Thanks very much!

I also have found this solution, but I was dount whether it's a good
answer for my problem at first.

But until now I still can't find a better method like this, and
according your description, maybe this already is what I'm looking
for.

Sorry for I'm not familiar with Vista. Thanks again!

On Sun, 21 Jan 2007 10:19:53 +0000, David Lowndes
<DavidL@example.invalid> wrote:

>
>If your application needs to run as the administrator it should have a
>manifest resource to indicates this.
>
>If you add the following information to any existing manifest file in
>your project it will cause Vista to prompt appropriately to have your
>application run as the administrator:
>
>  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
>    <security>
>      <requestedPrivileges>
>        <requestedExecutionLevel
>          level="requireAdministrator" uiAccess="false"/>
>      </requestedPrivileges>
>    </security>
>  </trustInfo>
>
>For more information on the subject try Googling for the terms:
>requestedExecutionLevel and requireAdministrator.
>
>Dave
0
hitterlee (1)
1/21/2007 8:07:18 PM
Reply:

Similar Artilces:

How to create a filter to see sharing records
Hi, With standard view you can see My_Active or All_Active records. You can't assign a record to a team... How I can see all records that other users share with me? Seems I can't find anything in the filter related to Sharing... Simple example: Each sales (user) has individual contacts but also there are common contacts among them that they would like to see, share and update. How I can filter contacts assigned to me and shared with me? Thanks, Eugene ...

Create new Exchange Mailbox without creating a new AD-User
I'm running Win2003SBS SP1 with Exchange2003 SP2. I would like to create funtional exchange-mailboxes (info@..., service@...) without creating a new AD-User as owner of these mailboxes. Owner should be an already existing AD-User. Is this possible and how could this be done. Thanks. Andreas Andreas Lauer IT Service wrote: > I'm running Win2003SBS SP1 with Exchange2003 SP2. > I would like to create funtional exchange-mailboxes (info@..., service@...) > without creating a new AD-User as owner of these mailboxes. Owner should be > an already existing AD-User. > Is thi...

Create Excell Chart.
Can I create one chart with two different data rows using two different date time frames? Bob - I assume your problem is that your dates overlap but do not exactly coincide, and Excel wants to use the first set of dates for both series. Here's how to work around that problem. Make your time-scale line chart with the first set of data (dates and values). Copy the second set of data (dates and values), select the chart, choose Paste Special from the Edit menu, and choose New Series and Categories in first row/column. Select the new series, choose Chart Type from the Chart menu, and ...

Quantity RTD ... On Order... Picked Up "Remove from printed receipt"
When we tender as a work order a receipt is printed. Below each item on the reciept the following items are also printed... We would like to omit (remove or hide) these items on the receipt if possible. Is this possible? Item Lookup Code........... Description.........................................Quantity......Price..... Ext Product1...........................Widgit...........................................................1.......$1.00...$1.00 ..........................................Quantity RTD............................................0 ............................................

How do I create a sign-up sheet?
I am using Microsoft Publisher 2003. I would like to create some sort of sign-up sheet including: name, phone #'s, email, address, ect. Use a table... -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Hawk" <Hawk@discussions.microsoft.com> wrote in message news:B0F7335B-9D2A-4131-A6C9-2B67E05E060C@microsoft.com... >I am using Microsoft Publisher 2003. I would like to create some sort of > sign-up sheet including: name, phone #'s, email, address, ect. Mary Sauer wrote: > Use a table... The exa...

cut removes border as well as contents
hi guys, i've created an excel worksheet that holds names in work groups. when i cut a name out of one workgroup to paste into another it removes the border as well. any ideas? i'm using excel 2000 regards bill Yes, Cut moves all aspects of a cell. The alternative is a copy/paste, followed by a Clear Contents of the source cell. -- Jim Rech Excel MVP thanks jim, i was hoping to protect the borders from people accidentally removing them in the event that they cuts the contents from one cell to paste into another regards bill "Jim Rech" <jrrech@hotmail...

APIs to create new folders under Start-All Programs ?
Hi: Is there SDK APIs to create new folders and put application links inside the groups under the Start-All Programs menu? Thanks in Advance. Polaris How about CreateDirectory()? "Polaris" <etpolaris@hotmail.com> wrote in message news:OvItfufdEHA.3420@TK2MSFTNGP12.phx.gbl... > Hi: > > Is there SDK APIs to create new folders... Thanks. But the new directoy created will not shown under Start-All Programs menu. I like to create a new folder under Start - All Programs for my applications. "David Crow [MCSD]" <david.no.spam.crow@pbsnow.no.spam.com>...

Help, keeps asking for passwor
I downloaded a MS template from the MS Download site. It's for Excel and it is a Monthly Timesheet. It keeps asking me for a password when I try to modify it for our company. HELP Where did you download it from and what is it called ? Regards Trevor "dkk" <anonymous@discussions.microsoft.com> wrote in message news:3F51C5E6-940A-42C7-BABB-DF89826992DC@microsoft.com... > I downloaded a MS template from the MS Download site. It's for Excel and it is a Monthly Timesheet. It keeps asking me for a password when I try to modify it for our company. > HELP Hi d...

Help with creating a formula
Hello! I am trying to create a formula that will sum up certain criteria from one column as it relates to criteria in the same row in another column. For example, I want to sum up all the entries that begin with the letter "H" in column A as it relates to an entry of "2" from column B that is in the same row as the "H" entry from column A. COLUMN A COLUMN B H10 2 G01 2 H09 3 H15 2 H12 2 If there is such a formula...

Microsoft .NET Framework 1.1 SP1 Security Update for Windows Vista
Microsoft .NET Framework 1.1 SP1 Security Update for Windows Vista and Windows Server 2008 (KB979906) This update fails to install, with error code 643. I am operating Windows Vista SP2 I have Microsoft .net Framework 1.1 installed, the hotfix for 1.1 (KB929729) and Microsoft .net Framework 3.5 SP1 Hello JM, You might want to look at the following kb article to see if this will help with the error 643. <http://windows.microsoft.com/en-US/windows-vista/Windows-Update-error-80070643> Please let us know if this helps. if not wait for more responses -=- &q...

Background Banking Continually Fails on Vista
Folks, I've installed Money Plus as an upgrade to Money 2007. I get a continual failure after any update activity where Microsoft Background Banking has stopped working. I'm not even sure what this is breaking, but it's a new error and I've found no documentation at all on what may be causing it. I checked my Windows Firewall, and have made sure MoneyPlus is allowed through. I'm checking into my AV program too to make sure it's current. Thoughts? Pashman On Nov 4, 6:56 pm, Pashman <Pash...@discussions.microsoft.com> wrote: > Folks, > I've in...

Excel 2007 .xlk file
Can anyone tell me why Excel 2007 will sometimes create a backup file, on its own, with a .xlk extension? I've searched Excel help, the Internet, and MS's site, but can't find any info. I'm interested to know under what circumstances these files are created, because the behavior seems a bit random to me. Thanks Not random at all. A backup file is created when that option is set for the file in question. It is set on the file itself. See, Save As, Tools, General Options, Always create backup. Tony wrote: > Can anyone tell me why Excel 2007 will ...

Create Assembly Call
hi All, can the create assembly call under update entity be used to add a certain number of hours/days/months/years to a date. i am trying to do this workflow if variable 1 = yes then create a task update variable 1 sent = yes variable 1 date = execution time can i use the create assembly workflow to add x number of days to variable 1 date and show in variable 2 date. any advice would be helpful please. thanks heaps regards Ridhima If Variable 1 Date is a DateTime field in CRM, then yes. You can use the Add DateTime assembly to take the Value in the DateTime field (which would be t...

Tables being created by opening form
I'm using Access 2003 with a sql server back-end. One form I've designed, when opened, creates a local table called "Admin - 00", with the number incrementing each time the form is opened. I assume Admin is the username. The table has 1 column named "ODBC" of type memo. The table is filled with 302 rows of the following string: 01004 - 0 - [Microsoft][ODBC SQL Server Driver]String data, right truncation If I open the form into design mode directly, 2 tables with 151 rows of the above are created. The form itself is a 'single form' view with no recordset. ...

Creating charts with objects in excel
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: Intel I am trying to put statistical information in bar charts created in Excel. I put asterisks in text boxes and draw lines below them to show which groups are being compared. The program does not seem to want to let me group them all, maybe there is a limit to how much you can group? So, to keep them from moving, I tried to save as a picture in a jpeg or png format but not all the lines and asterisks are showing up. I am finding this program extremely frustrating to use and hope I don't lose my mind before I finish my the...

Create Addin for Excel 2007 template
I have an Excel template that I already customized all the Ribbon's controls such as disabling SaveAs, Print, etc. I'm looking for a way that I can create and integrate an Addin into Excel such that whenever I open up a excel workbook, it will load up the workbook into my template. Can you please point me where I can get further instructions on that? Thanks and appreciate for your help. ...

create wmf in excel
Hi, hoping I can get some advise in producing a wmf file from an excel worksheet. The purpose is to import into powerpoint. cheers scott Unless you have an application capable of saving as .wmf (I use Illustrator), I think you will have to select the data and Shift+Edit>Copy picture, which I believe copies as a .bmp. -- Greeting from the Gulf Coast! http://myweb.cableone.net/twodays "scott" <anonymous@discussions.microsoft.com> wrote in message news:06f701c3b2fc$f9f3c0f0$a401280a@phx.gbl... > Hi, hoping I can get some advise in producing a wmf file > from an excel...

How do I set a Trend Line and Remove the Data Line
Is it possible to add a trend line to a chart but remove the data line from view and still keep the data available on the chart? Hi, Rather than remove the series that the trend line is based upon format it to have no markers or line colour. Cheers Andy -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info "FlexoC" <FlexoC@discussions.microsoft.com> wrote in message news:C7C5C91D-06F6-44FF-A095-0307844D876F@microsoft.com... > Is it possible to add a trend line to a chart but remove the data line > from > view and still keep the data available on the ...

Create Site Link
This is a multi-part message in MIME format. ------=_NextPart_000_0009_01CB1A1D.BCC768F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am trying to create a Site Link Object on a server core machine using = new-adobject cmdlet, however the below syntax fails. Pls assist new-adobject -name "US-AU" -type siteLink -Path "CN=3DIP,CN=3DInter-Site = Transports,CN=3DSites,CN=3DConfiguration,DC=3Dcausal,DC=3Dcom" The error message is like below New-ADObject : A required attribute is missing At line:1 char:...

SumIf
Hi =SUMIF(A6:A2000,"(left(a6:a2000,4))=(left($K$14,4))",F6:F2000) I want to create a sub total of all values in column F, at certain subtotal cells in column F where the the first 4 (or other to be set)characters of a code in cells a6 to a2000 match the first 4 characters in cell$K$14 (or other cell to be set). The above doesn't seem to work, is it possible? am I missing something? Any help would be greatly appreciated. Ritchi Try this array* formula: =SUM(IF(LEFT(A$6:A$2000,4)=LEFT($K$14,4),F$6:F$2000,0)) * As this is an array formula, then once you have typed it in (or s...

help how do i create a postcard to send by email?
hi i would like to know which are the steps to create a post card and then send it by email thru hotmail or yahoo. to my contacts to see it but not as an attachment i want it in the body of the text. iam a newbie so please explain me clear if you can. thanks and sorry! -- judy The only way to do that would be if you created it, saved it as a .gif or a ,jpg and inserted that. To do it any other way would require you to use Outlook or Outlook Express. -- JoAnn Paules MVP Microsoft [Publisher] "judy" <judy_torres190@hotmail.com> wrote in message news:19A7D626-FDA1-...

Creating directory on Outlook 2002 Pro Shortcut Bar
I am trying to get my mail organized and was wondering if there is a way to create a directory on the Outlook 2002 Shortcut Bar? Earlier I imported mail from Outlook Express a couple of times and it made a disorganized mess. For reasons unknown, my Outlook Express Mail Program keeps crashing Don't forget to change the (at) in my e-mail address to the correct symbol. Please e-mail me a response Thank Do you mean a new group on the shortcut bar. Right click in an open area of the shortcut bar and select New Group. --� Milly Staples [MVP - Outlook] Post all replies to the group...

Ask your advice.
Hi all, We have exchange 2003 SP2 windows 2003 R2 envir. We have 4GB RM on the server. We have 10 mailbox stores. Now I need to create one mailbox store for several users (new dept) and should I put these users to the existing mailbox stores or create seperate mailbox store for these users? What's the memory penalty if I put these userson the new seperate mailbox store (from memory perspective?) Thank you! It probably doesn't matter much. -- Ed Crowley MVP "There are seldom good technological solutions to behavioral problems." .. "e...

Outlook asks for UID, Password & Domain
I am using Outlook 2000 on and XP Pro machine. I just bought 7 machines and reinstalled outlook on all my machines on an SBS 4.5 exchange client system. All but two machines work fine. For some reason on my machine and a second on the network, when I start Outlook I get a pop up box asking for username, password and domain. Once I install that info i get in. But when I close outlook and restart it, it does the same thing. buzz See if this article applies to you; http://support.microsoft.com/?id=321652 Also fix your system time; you're posting from the future! -- Robert Spa...

create a chart in word from cells in excel for specific individua
I am merging information into word from an excel spreadsheet for about 400 individuals. I want to create an individual chart in word for each person specific to their information. I can either pull the info from excel or use the merged info in the individualized word documents to create the chart. Without creating 400 charts, does anyone know how to accomplish this? ...