Advertisement
Leka74

File Association

Apr 6th, 2011
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. function File.SetAssociation(cExt, cExe, cIcon, cShort,cLong)
  2.     local cKey = cShort..".Document";
  3.     Registry.SetValue(HKEY_CLASSES_ROOT, cExt, "", cKey);
  4.     Registry.SetValue(HKEY_CLASSES_ROOT, cKey, "",cLong);
  5.     Registry.SetValue(HKEY_CLASSES_ROOT, cKey.."\\DefaultIcon","",File.GetShortName(cIcon)..",0");
  6.     Registry.SetValue(HKEY_CLASSES_ROOT, cKey.."\\shell\\open\\command", "", "\""..cExe.."\" \"%1\"");
  7. end
  8.  
  9. --[[ Example:
  10. File.SetAssociation(".test1234", _SourceFolder.."\\autorun.exe", _SourceFolder.."\\autorun.exe", "test", "test1243");
  11. TextFile.WriteFromString(_DesktopFolder.."\\test.txt", "Hello, world.", false);
  12. Crypto.BlowfishEncrypt(_DesktopFolder.."\\test.txt", _DesktopFolder.."\\test.test1234", "test1234");
  13. File.Delete(_DesktopFolder.."\\test.txt", false, false, false, nil);
  14. ]]
  15.  
  16. function File.RemoveAssociation(cExt, cShort)
  17.     local cKey = cShort..".Document";
  18.     Registry.DeleteKey(HKEY_CLASSES_ROOT, cExt);
  19.     Registry.DeleteKey(HKEY_CLASSES_ROOT, cKey);
  20. end
  21.  
  22. --[[ Example:
  23. File.RemoveAssociation(".test1234", "test");
  24. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement