noob question pointers + WINAPI

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
so i am trying to mix pointers and winapi i have some confusion

#include <windows.h>
#include <tchar.h>
#include <urlmon.h>

#pragma comment(lib, "UrlMon.lib")

struct Data
{
  HRESULT hr;
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
};

int main()
{
  Data *pData = new Data();
  
  const TCHAR url[] = _T("http://192.168.1.37:8000/putty.exe");
  const TCHAR path[] = _T("C:\\Intel\\Logs\\putty.exe");
  
  pData->hr = URLDownloadToFile(0, url, path, 0, 0);
  
// now here comes the confusion part //

  ZeroMemory(pData->&si, sizeof(pData->si));

// that line is wrong , works good without using arrow pointer but i am trying to use it anyways compiler says error , expected a member name
   ZeroMemory(&si, sizeof(si));

// this is correct way, but again, how to use zeromemory with structs ?
Last edited on
An easy way:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <windows.h>
#include <tchar.h>
#include <urlmon.h>

#pragma comment(lib, "UrlMon.lib")

struct Data
{
  HRESULT hr;
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
};

int main()
{
  Data data = {0};

  const TCHAR url[] = _T("http://192.168.1.37:8000/putty.exe");
  const TCHAR path[] = _T("C:\\Intel\\Logs\\putty.exe");

  data.hr = URLDownloadToFile(0, url, path, 0, 0);
  data.si.cb = sizeof(STARTUPINFO);

  system("pasue");
  return 0;
}
Topic archived. No new replies allowed.