Tuesday, October 11, 2016

Create Shortcut with RunAs Administrator using VFP

Create Shortcut with RunAs Administrator using Visual FoxPro Code.

Function CreateShortcut
Lparameters lcExecutableFile,lcShortcutText,lcProgramDesc,llRunAsAdmin

lcTmpShortCutFile  = Addbs(Getenv("TEMP")) + Sys(2015)+".lnk"

oWsh = Createobject("wscript.shell")
cDeskpath = oWsh.SpecialFolders("desktop")

lcShortcutFile = cDeskpath+"\"+lcShortcutText+".lnk"
If llRunAsAdmin
oShort = oWsh.CreateShortcut(lcTmpShortCutFile)
oShort = oWsh.CreateShortcut(lcShortcutFile)

oShort.TargetPath = lcExecutableFile
oShort.WorkingDirectory = Addbs(Justpath(lcExecutableFile))
oShort.Description = lcProgramDesc

If llRunAsAdmin && Creating New Shortcut with RunAs option.

nhandle     = Fopen(lcTmpShortCutFile)
nFilesize     = Fseek(nhandle,0,2)
nhandle     = Fopen(lcTmpShortCutFile)

nHandle2     =  Fcreate(lcShortcutFile)
If nhandle     = -1  &&OR nHandle2 = -1
Wait Window [both source and destination files must be accessible]

nRemain     = nFilesize
i = 0
Do While !Feof(nhandle)
nChunk     = 1 && MIN(100,nRemain)
cTake     = Fread(nhandle,nChunk)

If i=21
cTake = Chr(32)  && a[0x15] |= 0x20; // flip the bit.  for RunAsAdmin

nRemain = nRemain - nChunk

i = i + 1
If nRemain = 0

Delete File "&lcTmpShortCutFile"

Saturday, March 22, 2014

Class Library Toolbox Icon

Step 1: 

Create bmp file (16x16) and save as like below.


  e.g. Project Name : CustomGrid
        Control Name : MyGridControl

Bmp File Name :  CustomGrid.MyGridControl.bmp

Step 2: Add in Project and Change Build Action Properties to "Embedded Resources".

Stpe 3: Add ToolboxBitmap line in your class file as per screenshot.

Step 4 : Compile your Project as "Class Library".

Step 5:  Add this control in Different Solution Project Toolbox using choose items and icon will display like below ( In Same Project icon can not display).

Download Complete Source : CustomGrid.Zip

Wednesday, May 1, 2013

x86 and x64 Bit Dll Issue

Only use the x86 DLL and make sure that the application build platform is x86 and the platform target is x86, because the 64 bit can run the x86 normally.
 To find those you should go to the application properties, and then at the build  tab you'll find them.
To Create new platform with x86, you have to locate the platform combo box beside the "Start Debugging" or "Play" or "RUN" button, and select the "configuration manager" from it.
Hope this will help.

Wednesday, January 2, 2013

Capture Screen with Menu

This Application will capture screen with Open Menu. (e.g. File Menu, Windows Start Menu)

It will works with Windows 7 Basic Themes & Aero Themes.