Do you ever bother checking the internet before you ask questions here? You might find what you are looking for. Lots of information is available to those who look.
If I read correctly or ExtCreatePen() function, with LOGBRUSH::lbHatch, can do it?
"A hatch style. The meaning depends on the brush style defined by lbStyle.
If lbStyle is BS_DIBPATTERN, the lbHatch member contains a handle to a packed DIB. To obtain this handle, an application calls the GlobalAlloc function with GMEM_MOVEABLE (or LocalAlloc with LMEM_MOVEABLE) to allocate a block of memory and then fills the memory with the packed DIB. A packed DIB consists of a BITMAPINFO structure immediately followed by the array of bytes that define the pixels of the bitmap." https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-extcreatepen https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-logbrush
(sorry been late to answer, but i didn't get the notification)