> ## Documentation Index
> Fetch the complete documentation index at: https://docs.joinmassive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Windows embedded

> Integrate Massive embedded SDK into your Windows C/C++ application with this guide.

## Example code

```c theme={null}
#include <Massive.h>

...

void initCallback(MassiveStatus status, void *context) {
  if (status == OP_SUCCESS) {
    if (MassiveStart() == OP_SUCCESS) {
      bool isMassiveStarted = false;
      MassiveIsStarted(&isMassiveStarted);

      if (isMassiveStarted) MassiveStop();
    }
  }
}

MassiveInitWithAPIToken(apiToken, initCallback, context);

...

MassiveCleanUp();
```

## Getting started

1. Download the [latest embedded SDK package][3].

2. Extract the package to your folder of choice.

3. Open your IDE and the project you want to integrate the SDK into.

4. Add the extracted `include` folder to your include path.

5. Add the `lib\win64\static-crt` folder to your library path and, from that
   folder, the `MassiveService.lib` library as a dependency.

6. Configure the `MassiveService.dll` library to be copied, at build time, from
   the `lib\win64\static-crt` folder to your output folder.

7. In your implementation file, import the SDK:

   ```c theme={null}
   // Importing in C/C++:
   #include <Massive.h>
   ```

8. Start and wait till the SDK is ready by calling the `MassiveInitWithAPIToken`
   function and defining a `MassiveInitCallback` continuation function:

   ```c theme={null}
   // Starting in C/C++:
   MassiveInitWithAPIToken(apiToken, initCallback, context);

   void initCallback(MassiveStatus status, void *context) {
     if (status == OP_SUCCESS) {
       ...
     }
   }
   ```

9. When the user opts in, call the `MassiveStart` function:

   ```c theme={null}
   // Opting in in C/C++:
   MassiveStart();
   ```

10. When the user opts out, call the `MassiveStop` function:

    ```c theme={null}
    // Opting out in C/C++:
    MassiveStop();
    ```

See the [API reference][6] for detailed info and optional SDK functionality.

## API reference

### Types

**`typedef enum MassiveStatus`**

An enumeration of possible states of the Massive SDK.

**Values**

**`OP_SUCCESS`** The operation was successful.

**`INVALID_ARGS`** The arguments passed to the function were invalid.

**`UNINITIALIZED`** The Massive SDK was not initialized.

**`INITIALIZING`** The Massive SDK is initializing.

**`INTERNAL_ERROR`** An internal error occurred.

***

**`typedef void(__cdecl *MassiveInitCallback)(MassiveStatus status, void *context);`**

A function called with the result of the Massive SDK's initialization. The
startup state and local data from the caller are passed to the function.

**Parameters**

**`status`** The startup state of the SDK.

**`context`** Any local data passed to the `MassiveInitWithAPIToken` function.

***

**`typedef void(__cdecl *MassiveStatisticDataCallback)(const char *const data, size_t size, void *context);`**

A function called asynchronously with the usage statistics requested by the
`MassiveGetComputationStatistics` function.

**Parameters**

**`data`** The statistics, as a JSON array with one entry per sample.

**`size`** The size of `data` in bytes.

**`context`** Any local data passed to the `MassiveGetComputationStatistics`
function.

***

### Functions

**`MassiveStatus __cdecl MassiveOptionsSetDataBasePath(const wchar_t *path);`**

Sets the folder for the SDK's data and log. Call it before the
`MassiveInitWithAPIToken` function.

**Parameters**

**`path`** An absolute path, or an empty string for the default folder.

**Return value**

Execution status code.

***

**`void __cdecl MassiveInitWithAPIToken(const char *apiToken, MassiveInitCallback callback, void *userData);`**

Initializes the Massive SDK, pending user opt-in, attributed to your API token.

**Parameters**

**`apiToken`** A unique developer identifier obtained from the [applications](https://sdk.joinmassive.com/applications) page.

**`callback`** A function called with the result of the initialization.

**`userData`** Any local data to pass to the `callback` function.

***

**`void __cdecl MassiveCleanUp();`**

De-initializes and releases all resources acquired by Massive.

***

**`const char *__cdecl MassiveGetVersion();`**

Returns the version of the Massive SDK.

**Return value**

The version of the Massive SDK in the format `major.minor.patch`.

***

**`MassiveStatus __cdecl MassiveStart();`**

Allows computing resources to be opportunistically consumed. The user must agree
to easy-to-understand terms of the exchange you’re offering before you call this
function.

**Return value**

Execution status code.

***

**`MassiveStatus __cdecl MassiveStop();`**

Disallows computing resources to be consumed.

**Return value**

Execution status code.

***

**`MassiveStatus __cdecl MassiveIsStarted(bool *isStarted);`**

Queries whether the node runs.

**Parameters**

**`isStarted`** Receives the state.

**Return value**

Execution status code.

***

**`MassiveStatus __cdecl MassiveIsMonetizing(uint32_t minutes, bool *isMonetizing);`**

Queries whether the node runs and has relayed traffic since it started, or within
the last `minutes` minutes.

**Parameters**

**`minutes`** How far to look back, in minutes. `0` means since the node started.

**`isMonetizing`** Receives the answer.

**Return value**

Execution status code.

***

**`MassiveStatus __cdecl MassiveGetComputationStatistics(const time_t from, const time_t to, const uint16_t samples, MassiveStatisticDataCallback callback, void *context);`**

Requests the usage statistics over a period, cut into samples.

**Parameters**

**`from`** The start of the period, in seconds since 1970-01-01 UTC.

**`to`** The end of the period, in seconds since 1970-01-01 UTC.

**`samples`** How many equal parts to cut the period into.

**`callback`** A function called asynchronously with the statistics.

**`context`** Any local data to pass to the `callback` function.

**Return value**

Execution status code.

[3]: https://sdk.joinmassive.com/downloads

[6]: #api-reference


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.