在 C++ 中打开 Windows 资源管理器窗口
Opening a Windows Explorer Window in C++
我最近为一个学校项目编写了以下代码;我的目标是制作一个基本的加密程序。目前要使用此程序加密文件,需要知道文件名并手动输入控制台,包括文件扩展名。为了提高程序的用户友好性,我想实现一个功能来打开Windows文件资源管理器窗口,以便用户可以选择要加密的文件。在互联网上进行了大量搜索后,我无法找到任何将其实现到我的代码中的方法。所以我的问题是,此功能是否存在于C++库中,如果是,我该如何将其实现到我的代码中。
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
using namespace std;
#define ENCRYPTION_FORMULA (int) Byte * 25
#define DECRYPTION_FORMULA (int) Byte / 25
int Encrypt (char * FILENAME, char * NEW_FILENAME)
{
std::ifstream inFile;
std::ofstream outFile;
char Byte;
inFile.open(FILENAME, ios::in | ios::binary);
outFile.open(NEW_FILENAME, ios::out | ios::binary);
while(!inFile.eof())
{
char NewByte;
Byte = inFile.get();
if (inFile.fail())
return 0;
NewByte = ENCRYPTION_FORMULA;
outFile.put(NewByte);
}
inFile.close();
outFile.close();
return 1;
}
int Decrypt (char * FILENAME, char * NEW_FILENAME)
{
std::ifstream inFile;
std::ofstream outFile;
char Byte;
inFile.open(FILENAME, ios::in | ios::binary);
outFile.open(NEW_FILENAME, ios::out | ios::binary);
while(!inFile.eof())
{
char NewByte;
Byte = inFile.get();
if (inFile.fail())
return 0;
NewByte = DECRYPTION_FORMULA;
outFile.put(NewByte);
}
inFile.close();
outFile.close();
return 1;
}
int main()
{
char EncFile[200];
char NewEncFile[200];
char DecFile[200];
char NewDecFile[200];
int Choice;
cout << "NOTE: You must encrypt the file with the same file extension!"<<endl;
cout << "Enter 1 to Encrypt / 2 to Decrypt"<<endl;
cin >> Choice;
switch(Choice)
{
case 1:
cout << "Enter the current Filename: ";
cin >> EncFile;
cout << "Enter the new Filename: ";
cin >> NewEncFile;
Encrypt(EncFile, NewEncFile);
break;
case 2:
cout << "Enter the current Filename: ";
cin >> DecFile;
cout << "Enter the new Filename: ";
cin >> NewDecFile;
Decrypt(DecFile, NewDecFile);
break;
}
return 0; //Exit!
}
您引用的"打开文件"对话框是 Windows API 的一部分。要添加它,您必须编写一堆代码,这对于手头的任务来说可能不值得。如果您仍然想这样做,请在 MSDN 上阅读有关它的更多信息。
相关文章:
- Windows 资源管理器中的图标在使用 resource.rc 时显示 2 个不同的图标
- Windows 资源管理器打开文件夹还原
- 如何在 Windows 资源管理器中捕获用户的左键单击?
- Windows 资源管理器右键单击文件和文件夹的上下文菜单
- Windows 资源管理器覆盖图标 - 如何开始
- IShellFolder.EnumObjects-windows资源管理器上的异步
- QTreeWidget:类似于Windows资源管理器的编辑
- MFC:类似于Windows资源管理器的应用程序,可以与主线程并行导出文件
- 无法在Eclipse中运行SDL程序,但可以在Windows资源管理器中运行
- Qt应用程序中的Windows资源管理器
- 在 Windows 资源管理器中更改当前路径
- 如何拦截从Windows资源管理器启动的exe文件
- 在 C++ 中打开 Windows 资源管理器窗口
- 如何显示 Windows 资源管理器上下文(右键单击)菜单
- 如何在 Windows 资源管理器中嵌入我的 GUI
- 检索 Windows 资源管理器的地址栏编辑控件的句柄
- 如果Windows资源管理器正在运行,Direct3D应用程序运行良好,否则速度会非常慢
- 在windows资源管理器中复制文件夹
- QT应用程序在Windows资源管理器上不起作用?
- 如何在Windows资源管理器中获得由_rmdir删除的目录以立即更新