示例#1
0
文件: shlink.cpp 项目: pombreda/main
	ShellLink::ShellLink(PCWSTR path, bool write) :
		m_path(path)
	{
		Object<IPersistFile> ppf;
		CheckApiError(::CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IPersistFile, (PVOID* )&ppf));
		CheckCom(ppf->Load(m_path.c_str(), write ? STGM_READWRITE : STGM_READ));

		CheckCom(ppf->QueryInterface(IID_IShellLink, (PVOID*)&m_lnk));

		CheckCom(m_lnk->Resolve(NULL, SLR_ANY_MATCH | SLR_NO_UI));
	}
示例#2
0
	ssize_t ArchiveExtract::execute()
	{
		LogTrace();
		Com::Object<IArchiveExtractCallback> extractCallback(new ExtractCallback(m_archive, m_dest));
		CheckCom(m_archive->Extract(nullptr, (UInt32 )-1, false, extractCallback));
		return 0;
	}
示例#3
0
文件: shlink.cpp 项目: pombreda/main
	ShellLink ShellLink::create(PCWSTR path)
	{
		ShellLink ret;
		ret.m_path = path;
		CheckCom(::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (PVOID*)&ret.m_lnk));
		return ret;
	}
示例#4
0
	void Archive::open_archive(const Lib & lib, const ustring & path)
	{
		LogNoise(L"%p, '%s'\n", &lib, path.c_str());
		Com::Object<IInStream> stream(new FileReadStream(path));
		Com::Object<IArchiveOpenCallback> openCallback(new OpenCallback);
		for (auto it = lib.codecs().begin(); it != lib.codecs().end(); ++it) {
			LogNoise(L"codec: '%s'\n", it->name.c_str());
			CheckCom(stream->Seek(0, STREAM_SEEK_SET, nullptr));
			CheckCom(lib.CreateObject(&it->guid, &IID_IInArchive, (PVOID*)&m_arc));
			if (m_arc->Open(stream, &max_check_size, openCallback) == S_OK) {
				m_codec = it;
				return;
			}
		}
		CheckApiError(ERROR_INVALID_DATA);
	}
示例#5
0
文件: shlink.cpp 项目: pombreda/main
	ShellIcon ShellLink::icon() const
	{
		Base::auto_array<wchar_t> buf(Base::MAX_PATH_LEN);
		int ind;
		CheckCom(m_lnk->GetIconLocation(buf.data(), buf.size(), &ind));

		return ShellIcon(ustring(buf.data()), ind);
	}
void ComIO::OpenAndInitCom()
{
  /*
  hCom = OpenCommPort(ComIndex);
  if(hCom)
    CommPort_Init(hCom);*/
  if(CheckCom(ComIndex))
  {
    printf("Find Com%d\r\n", ComIndex);
    return ;
  }
  for(int i = 0; i < 20; i++)
  {
    if((i != ComIndex) && CheckCom(i))
    {
      printf("Find Com%d\r\n", i);
      break;
    }
  }
}
示例#7
0
	void Methods::cache(const Lib & lib)
	{
		UInt32 num_methods = 0;
		CheckCom(lib.GetNumberOfMethods(&num_methods));

		clear();

		for (size_t idx = 0; idx < num_methods; ++idx) {
			emplace_back(lib, idx);
		}
	}
示例#8
0
文件: shlink.cpp 项目: pombreda/main
	int ShellLink::show() const
	{
		int ret;
		CheckCom(m_lnk->GetShowCmd(&ret));
		return ret;
	}
示例#9
0
	ArchiveSequence::const_iterator ArchiveSequence::at(size_t index) const
	{
		if (index >= size())
			CheckCom(TYPE_E_OUTOFBOUNDS);
		return const_iterator(*this, index);
	}
示例#10
0
文件: shlink.cpp 项目: pombreda/main
	void ShellLink::show(int in)
	{
		CheckCom(m_lnk->SetShowCmd(in));
	}
示例#11
0
文件: shlink.cpp 项目: pombreda/main
	void ShellLink::descr(const ustring &in)
	{
		CheckCom(m_lnk->SetDescription(in.c_str()));
	}
示例#12
0
文件: shlink.cpp 项目: pombreda/main
	void ShellLink::path(const ustring &in)
	{
		CheckCom(m_lnk->SetPath(in.c_str()));
	}
示例#13
0
文件: shlink.cpp 项目: pombreda/main
	void ShellLink::args(const ustring &in)
	{
		CheckCom(m_lnk->SetArguments(in.c_str()));
	}
示例#14
0
文件: shlink.cpp 项目: pombreda/main
	void ShellLink::write() const
	{
		Object<IPersistFile> ppf;
		CheckCom(m_lnk->QueryInterface(IID_IPersistFile, (PVOID* )&ppf));
		CheckCom(ppf->Save(m_path.c_str(), FALSE));
	}
示例#15
0
文件: shlink.cpp 项目: pombreda/main
	ustring ShellLink::args() const
	{
		Base::auto_array<wchar_t> buf(Base::MAX_PATH_LEN);
		CheckCom(m_lnk->GetArguments(buf.data(), buf.size()));
		return ustring(buf);
	}
示例#16
0
文件: shlink.cpp 项目: pombreda/main
	ustring ShellLink::path() const
	{
		Base::auto_array<wchar_t> buf(Base::MAX_PATH_LEN);
		CheckCom(m_lnk->GetPath(buf.data(), buf.size(), nullptr, 0));
		return ustring(buf);
	}
示例#17
0
文件: shlink.cpp 项目: pombreda/main
	ustring ShellLink::descr() const
	{
		Base::auto_array<wchar_t> buf(Base::MAX_PATH_LEN);
		CheckCom(m_lnk->GetDescription(buf.data(), buf.size()));
		return ustring(buf);
	}
示例#18
0
文件: shlink.cpp 项目: pombreda/main
	ustring ShellLink::work_dir() const
	{
		Base::auto_array<wchar_t> buf(Base::MAX_PATH_LEN);
		CheckCom(m_lnk->GetWorkingDirectory(buf.data(), buf.size()));
		return ustring(buf.data());
	}
示例#19
0
文件: shlink.cpp 项目: pombreda/main
	void ShellLink::work_dir(const ustring &in)
	{
		CheckCom(m_lnk->SetWorkingDirectory(in.c_str()));
	}