int shellExecute()

in ffi/system-command/windows.dart [40:60]


int shellExecute(String operation, String file) {
  // Load shell32.
  final dylib = ffi.DynamicLibrary.open('shell32.dll');

  // Look up the `ShellExecuteW` function.
  final shellExecuteP =
      dylib.lookupFunction<ShellExecuteC, ShellExecuteDart>('ShellExecuteW');

  // Allocate pointers to Utf8 arrays containing the command arguments.
  final operationP = operation.toNativeUtf16();
  final fileP = file.toNativeUtf16();
  const int SW_SHOWNORMAL = 1;

  // Invoke the command, and free the pointers.
  var result = shellExecuteP(
      ffi.nullptr, operationP, fileP, ffi.nullptr, ffi.nullptr, SW_SHOWNORMAL);
  calloc.free(operationP);
  calloc.free(fileP);

  return result;
}