- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个程序和一个包含几行信息的 .l2p 文件。我运行了一个注册表文件:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.l2p\DefaultIcon]
@="\"C:\\Program Files\\ToriLori\\L2P.exe\",0"
[HKEY_CLASSES_ROOT\.l2p\shell\Open\command]
@="\"C:\\Program Files\\ToriLori\\L2P.exe\" \"%1\""
当我双击 .l2p 文件时,程序启动但不加载文件。我需要做什么才能使其正确加载?示例代码将不胜感激。
最佳答案
当您双击文件时,文件名将作为命令行参数传递给相关程序。您必须解析命令行,获取文件名并打开它(如何执行取决于您的程序的工作方式)。
#include <iostream>
int main(int argc, char *argv[])
{
for (int i = 1; i < argc; ++i) {
std::cout << "The " << i << "th argument is " << argv[i] << std::endl;
}
}
如果你从命令行运行这个程序:
>test.exe "path/to/file" "/path/to/second/file"
The 1th argument is path/to/file
The 2th argument is /path/to/second/file
在 Qt 中,如果您创建 QApplication,您还可以通过 QCoreApplications::arguments() 访问命令行参数.
您可能希望在创建主窗口后加载该文件。你可以这样做:
#include <QApplication>
#include <QTimer>
#include "MainWindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow window;
QTimer::singleShot(0, & window, SLOT(initialize()));
window.show();
return app.exec();
}
这样,槽 MainWindow::initialize()
(您必须定义)在事件循环开始后立即被调用。
void MainWindow::initialize()
{
QStringList arguments = QCoreApplication::arguments();
// Now you can parse the arguments *after* the main window has been created.
}
关于windows - Qt - 通过双击打开自定义文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10994339/
我正在尝试从 Android 连接到本地主机中的 Apache Vysper XMPP 服务器。我正在使用 Smack执行 XMPP 操作的框架: AbstractXMPPConnection con
我不断收到相同的错误消息。起初我认为这是超时问题,所以我设置了 .setPacketReplyTimeout(15000); 仍然只是碰巧等待更长时间然后显示相同的错误消息。在更深入的发现中,我发现这
我正在尝试使用 asmack(Android Gingerbread)连接到 google talk。我已经设置了 connectionConfig.setTruststoreType("BKS")
我正在开发一对一聊天,但我面临服务器需要 SSL/TLS 但在客户端禁用的问题,不知道我做错了什么,请帮我找出错误 我的服务等级: class ChatService:Service() {
我是一名优秀的程序员,十分优秀!