-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwork.c
More file actions
85 lines (73 loc) · 2.09 KB
/
work.c
File metadata and controls
85 lines (73 loc) · 2.09 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// what u gonna do when wh off your line, what u go nn ad o?
#include <windows.h>
#include <mmsystem.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <stdbool.h>
int main(void)
{
int ret;
int file_count = 0;
int max_iterations = 1000; // Prevent infinite loop
int current_iteration = 0;
srand(time(NULL));
HANDLE fh;
WIN32_FIND_DATA fd;
int c=0;
int curc=0;
while (current_iteration < max_iterations)
{
current_iteration++;
// First pass: count files
file_count = 0;
memset(&fd, 0x0, sizeof(fd));
fh = FindFirstFile("e:\\work\\*.wav", &fd);
if (fh != INVALID_HANDLE_VALUE)
{
do
{
file_count++;
}
while (FindNextFile(fh, &fd));
FindClose(fh);
}
if (file_count == 0)
{
printf("No .wav files found in e:\\work\\\n");
break;
}
// Select random file index
c = rand() % file_count;
// Second pass: get the selected file
memset(&fd, 0x0, sizeof(fd));
fh = FindFirstFile("e:\\work\\*.wav", &fd);
// deb("dump fh: %x", fh);
curc=c;
if (fh != INVALID_HANDLE_VALUE)
{
// Skip to the selected file
while (curc > 0 && FindNextFile(fh, &fd))
{
curc--;
}
printf("Playing file %u: %s\n", c, fd.cFileName);
char fn[MAX_PATH];
sprintf(fn,"e:\\work\\%s",fd.cFileName);
ret=PlaySound(fn,NULL,SND_FILENAME);
if (!ret)
{
printf("Failed to play sound: %s (Error: %d)\n", fn, GetLastError());
}
FindClose(fh);
}
curc=0;
// printf("%d %d",ret,GetLastError());
// Add a small delay to prevent excessive CPU usage
Sleep(1000);
}
printf("Program completed after %d iterations\n", current_iteration);
return 0;
}
// just because not higher sh e
// 2025: still fighting